Treasure Hunt
Learn to code 1, Functions
We are currently learning to code on Swiftplayground, the video above is one of the challenges that we had to complete called ‘Treasure Hunt’. Our challenge was to decompose patterns and create our own functions. The first function that I made was to reach the switch, toggle it, turn around and reach the next switch, toggle it, turn around and walk back to where it started. Then I made the byte (the small character) turn to face the next row. Once the byte had turned around, it had to move to reach the first switch, then toggle the switch, reach the second switch, toggle it, turn around and then repeat. This code I found simple.
Comments
Post a Comment