Congratulations, I'm guessing this problem took you a bit to figure out. My
teaching assistant Congard de Kana came up with this problem so it was fun for
me to solve in my own way. The key insight for me was that each step needed to
be a constant distance up and forward from the previous step. From the second
step I started by adding the height of the first step to its location. This
first step's height is the vertical step's pieces height plus the step's
thickness. The other piece of the puzzle is how far forward the second step is
from the first. From the diagram we see that this is the horizontal step depth
minus the step thickness. With these two values in hand I could create a loop to
generate all of the steps. Here's my code. At the top I computed the height and
depth I needed to offset between each step. Through experimentation I found I
needed to make six steps with my loop. On each loop iteration I modified both
the vertical and horizontal parts of the step by adding in the height and depth
offsets.
達成おめでとう 解答には少々時間がかかったでしょう
アシスタントがこの問題を思いついた時
私は自分なりの方法で
楽しんでこの問題に取り組みました
理解のポイントは
階段が前の段から一定の距離で
上方向と前方向に移動することです
私は2段目の位置に1段目の半分の高さを加えました
1段目の高さは縦板の高さに階段の厚さを
足した高さになります
次に2段目が1段目から
どれだけ前方に移動するか考えました
この図からその距離は横板の奥行きから
階段の厚さを引いたものだと分かります
この2つの値を把握すると
すべての階段を生成するループができました
これが私のコードです
まず私が計算したのは
段と段の間で相殺される高さと奥行きです
その後の実験を通して
ループで6段の階段を作る必要があると分かりました
私はそれぞれのループで
縦板と横板のパーツの両方に
相殺分の高さと奥行きを取り込みました
恭喜,我猜這個問題會花你不少時間
助教 Congard de Kana 想到這個作業,我用我自己的方法解還蠻有趣的
主要想法是每一階往上與往前移動距離是固定的
我對第二階加上第一階的高度
第一階的高度是垂直盒子的高度加上水平盒子的厚度
另一個問題是下一階要往前多少
從圖可以看到我們要往前一階的深度減掉厚度
有這些資料我就能產生迴圈製造階梯
這是我的程式,我在一開始算出每一階往上往前的量
實驗後我發現需要用迴圈創造六階
在迴圈每次執行,我修改了垂直與水平盒子的位置
加上每階需要的高度與深度偏移