Discussion, solutions, tips, and bonus material for the Swift Playgrounds Learn to Code Activities:

These “Learn to Code” videos are intended for students and/or teachers who are interested in taking their programming to the next level.  We discuss one or more possible solutions for each Learn to Code activity and provide extra information on terminology, fundamentals and software design.

We recommend a user put serious effort into solving the Learn to Code activity on their own before consulting these videos.  Robust, long-term learning is best achieved by struggling, failing, and struggling again with the content.  After you have spent sufficient time and effort with the Learn to Code activity, watch the associated video solution and discussion for the activity below.

Compare your solution with ours.  If we presented a solution that was significantly different than yours, and you like it more that the one you produced, wait a few days and revisit the activity, this time trying to reproduce a solution that is different and better than your previous solution.  The extra guided practice you get recreating a solution after receiving feedback from these videos is key to better understanding and better code.

Swift Playgrounds – Learn to Code 1

Commands
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. Issuing Commands
  3. Adding a New Command
  4. Toggling a Switch
  5. Portal Practice
  6. Finding and Fixing Bugs
  7. Bug Squash Practice
  8. The Shortest Route
Functions
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. Composing a New Behavior
  3. Creating a New Function
  4. Collect, Toggle, Repeat
  5. Across the Board
  6. Nesting Patterns
  7. Slotted Stairways
  8. Treasure Hunt
For Loops
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. Using Loops
  3. Looping All the Sides
  4. To the Edge and Back
  5. Loop Jumper
  6. Branch Out
  7. Gem Farm
  8. Four Stash Sweep

** Bonus extra video on Functions and For Loops in Swift:  1000 Diamonds

Conditional Code
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. Checking for Switches
  3. Using else if
  4. Looping Conditional Code
  5. Conditional Climb
  6. Defining Smarter Functions
  7. Boxed In
  8. Decision Tree
Logical Operators
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. Using the NOT Operator
  3. Spiral of NOT
  4. Checking This AND That
  5. Checking This OR That
  6. Logical Labyrinth
While Loops
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. Running Code While …
  3. Creating Smarter While Loops
  4. Choosing the Correct Tool
  5. Four by Four
  6. Turned Around
  7. Land of Bounty
  8. Nesting Loops
  9. Random Rectangles
  10. You’re Always Right
Algorithms
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. The Right-Hand Rule
  3. Adjusting Your Algorithm
  4. Conquering a Maze
  5. Which Way to Turn
  6. Roll Right, Roll Left

 

Swift Playgrounds – Learn to Code 2

Variables
  1. Introduction – See Swift Playgrounds for introduction video
  2. Keeping Track
  3. Bump Up the Value
  4. Incrementing the Value
  5. Seeking Seven Gems
  6. Three Gems, Four Switches
  7. Checking for Equal Values
  8. Round Up the Switches
  9. Collect the Total
Types
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. Deactivating a Portal
  3. Portal On and Off
  4. Setting the Right Portal     (alternate solution video)
  5. Corners of the World    (alternate solution video)
  6. Random Gems Everywhere
Initialization
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. Initializing Your Expert   
  3. (Bonus Video – Introducing Swift Type Extensions)
  4. Train Your Expert
  5. Using Instances of Different Types
  6. It Takes Two
Parameters
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. Moving Further Forward
  3. Generalizing a Function
  4. Crank Up and Down – Solution 1
  5. Crank Up and Down – Solution 2
  6. Placing at a Specific Location
  7. Rivers to Cross
  8. Two Experts
  9. Twin Peaks
World Building
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. Uniting Worlds
  3. Connect and Solve
  4. Making Your Own Portals
  5. Reach for the Stars
  6. Floating Islands
  7. Build a Loop
  8. A Puzzle of Your Own
Arrays
  1. Introduction – See Swift Playgrounds Learn to Code iBook for introduction video
  2. Storing Information
  3. Iteration Exploration
  4. Stacking Blocks
  5. Getting in Order
  6. Appending to an Array
  7. Island Builder
  8. Appending Removed Values
  9. Fixing Array Out of Bounds Errors
  10. Generate a Landscape
  11. Randomized Lands
  12. Another Way to Create an Array
  13. The Art of the Array
  14. World Creation

 

Building Rainbows Extra Material:

Custom Types:

  1. Swift Custom Types – Building a Dog Walking Business App