Sponsored

Collapse

Announcement

Collapse
No announcement yet.

Corners of the World - Swift Playgrounds

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

  • Corners of the World - Swift Playgrounds

    The challenge of this level is to modify the state of two portals to solve the puzzle.

    For this challenge, there are lots of gems and switches in the puzzle world, with several portals to teleport through. That means there are lots of ways to solve the puzzle.

    As you write your code, try different solutions in your head to find the most efficient one. Writing efficient code results in a program that runs faster, which makes people using the app happy, and improves the battery life.

    Access the portals using greenPortal and orangePortal.

    Click image for larger version

Name:	Screen Shot 2017-01-02 at 2.31.49 AM.png
Views:	1158
Size:	349.9 KB
ID:	1292

    Hint: take a minute to examine the puzzle and see which of the skills you've learned so far will be most useful in solving it. There are many different solutions, so give one of your ideas a try! Just like in the previous puzzle, you'll need to use dot notation to modify the state of each portal instance separately. Example: greenPortal.isActive = true.

    Code:
    func TurnAround {
     turnLeft()
     turnLeft()
    }
    
    func collectToggle {
     if isOnGem {
      collectGem()
     } else if isOnClosedSwitch {
      toggleSwitch()
     }
    }
    
    func moveActTurn {
     moveForward()
     collectToggle()
     turnAround()
    }
    
    func solveHalf {
     moveActTurn()
     moveForward()
     turnLeft()
     moveActTurn()
    }
    
    func solveOtherHalf {
     moveActTurn()
     moveForward()
     turnRight()
     moveForward()
     collectToggle()
    }
    
    orangePortal.isActive = false
    turnRight()
    moveForward()
    moveForward()
    solveHalf()
    orangePortal.isActive = true
     ​moveForward()
    orangePortal.isActive = false
    solveHalf()
    moveForward()
    solveOtherHalf()
    moveForward()
    greenPortal.isActive = false
    moveForward()
    solveHalf()
    greenPortal.isActive = true
    moveForward()
    greenPortal.isActive = false
    solveHalf()
    moveForward()
    solveOtherHalf()
    Great Work! You just solved a tough challenge! By examining a problem and choosing which skills to use, you're teaching your brain to recognize how to solve a range of problems. As you gain experience, you'll be able to solve new problems more quickly and effectively.

    Next lesson is Random Gems Everywhere.

  • #2
     

    Comment


    • #3
      I have seen lot of puzzle games which really difficult to play and this game is really interesting and cool.This game is one steps ahead from the puzzle game.Some of people are playing this game which I have seen on the custom term paper writing services page and also found about tips to make mind more sharper.

      Comment

      Apple Swift Programming Language

      About this Group

      Discussion group for Swift programming language by apple for Xcode
      Type: Public
      Topics: 112
      Comments: 83

      Owner

      Sponsored Box

      Collapse

      Latest Group Topics

      Collapse

      There are no results that meet this criteria.

      Working...
      X