Sponsored

Collapse

Announcement

Collapse
No announcement yet.

Across the Board - Swift Playgrounds

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Across the Board - Swift Playgrounds

    In this level, the challenge is to identify a repeating pattern and define a function.

    In this challenge, there are lots of gems to collect, so many, in fact, that there are several ways to solve the puzzle.

    Choose a path that repeats a pattern, and use that pattern in your function.

    If your code doesn't work for the first time, keep playing with it, practice makes perfect! (But as always, you can move on whenever you're ready.)

    Hint to this level: recognizing the repeating patterns in the puzzle is key.

    The solution and coding to this level is show below:

    func repAct(){
    collectGem()
    moveForward()
    collectGem()
    moveForward()
    collectGem()
    }

    repAct()
    turnLeft()
    turnLeft()
    turnLeft()
    moveForward()
    turnLeft()
    turnLeft()
    turnLeft()
    repAct()
    turnLeft()
    moveForward()
    turnLeft()
    repAct()

    Great Work! You're writing and using your own functions. That's a major part of what it means to be a coder. With a function you can group commands together and call the function once to run the whole set of commands. Using functions makes code much more readable and understandable at a glance.

    Next level, you will be going to Nesting Patterns.
    Last edited by Royleeyy; 12-29-2016, 06:21 AM.
Working...
X