This script creates a zig zag pattern in the PowerShell window. The first section is a diagonal line starts going down and to the right. When it reaches the 50 character mark, it does the second section, heading down and to the left. In the first section, it just writes one more space each row it moves down. In the second section it writes one less space each row. To determine when it should switch direction, it runs this line:
This line does three operations: division, floor, and modulo. The division tells us how many full groups of 50 there are plus how big the partial group is. Taking the floor of a number rounds down to the integer. The floor of the division tells how many full groups of 50 there are. For instance, for the rows between 1 and 50, this is 0 and at row number 217, this is 4. The last part is “%2” which is the modulo operator with 2. This gives the remainder of a division with two. Any even number%2 will be zero and any odd number%2 will be 1. The end result is that every 50 rows, $StairDirection alternates between 0 and 1.
You can run this by downloading it and running this line in PowerShell, replacing “Path”:
It will go on forever so you can stop it by pressing Ctrl-C.