From today, we will enter the area of condition judgment = programming. I've gone through the textbook, so let's add some unique elements and make Hanoi for programming practice w An algorithm is like a textbook for judging conditions. I will make a condition judgment according to that algorithm application.
Let's make one program by printing the object only by conditional judgment. It will be a simple structure consisting of only a few statements.
The procedure is seven steps https://daeudaeu.com/hanoi/ http://www13.plala.or.jp/kymats/study/C++/Hanoi/Hanoi.html
Since I know the order of the answers, I can just move the object, but w In recursive processing, I would like to make it feel like a loop like returning and processing again without writing conditional judgments.
https://wa3.i-3-i.info/word14899.html
Head## White### juice####
I want to go with w
First of all, in order to cherish the image, first assemble in Japanese.
The computer doesn't work because it's useless to come up with it all at once and write it with a belief.
I think it is better to operate the parts and build while checking the operation one by one. It's the same as making gears one by one and moving the machine. It doesn't work with the mochi drawn in the picture w We will build parts by making them, moving them, expanding them, and moving them repeatedly.
1 = head ## 2 = white ### 3 = Juice #####
A = pan B = cooking C = bowl
if else while
0 = [_]
1 = ["Head##"]
2 = ["White###"]
3 = ["juice####"]
A=["Pan"]
B=["cooking"]
C=["Bowl"]
hanoi = ["_","Head##", "White###", "juice####"]
p hanoi [0]
p hanoi [1]
p hanoi [2]
p hanoi [3]
As for the image, the material like this is completed.
Next, prepare a stage and make parts to move the above materials.
・ Order It's the same as Basic, so you just need to build it in order from the top.
#Tower of Hanoi
#Condition judgment program practice
The algorithm. This is the place of the liver, so I would like to study it carefully, but if I do it properly, it will probably be a place where I can play for the rest of my life, but it's smooth.
The algorithm was written in old books with only small and difficult things, and I didn't understand it at all, but now there are many really nice and easy-to-understand ones. Computers and algorithms The first thing I learn in books is the Tower of Hanoi, but I haven't written how to use or write programs that apply Hanoi w The old algorithms were like that w So I don't understand at all. How do you use it? Like w
Hanoi is the first to learn algorithmic learning, but at the same time it becomes the basic learning of programming learning. It will be a basic practice, so the answer is to try making Hanoi after learning.
The aim of the Tower of Hanoi is to make a simple game as a tool for program education, and I think it's not something that can be done with this.
Algorithm picture book 370 yen https://apps.apple.com/jp/app/%E3%82%A2%E3%83%AB%E3%82%B4%E3%83%AA%E3%82%BA%E3%83%A0%E5%9B%B3%E9%91%91/id1047532631
Just looking at this is fun w There is a degree of understanding at all than an algorithm book w The uncle who went to NEC who was doing Fortran said that the processing is fast because he is familiar with the algorithm. It seems that the programmer's skill is an algorithm after all. Well that's right.
Recommended Posts