INCLUDES FREE UPDATES FOR SWIFT 6 AND BEYOND! Click here for full details.
Test your Swift. Challenge your friends. Prepare for coding interviews.
Swift Coding Challenges is an all-new book written from the ground up to put your Swift 5.0 skills to the test. I've written a variety of coding challenges that start off simple but slowly get harder, and it's down to you to solve them.
I outline each problem, provide you with sample input and output, add in some hints in case you hit problems, then provide a sample solution and explain how it works.
Give your coding brain the exercise it deserves!
Looking for a job?
If you're brushing up your skills in the hope of nailing a job interview, Swift Coding Challenges is for you. Never again fear the dreaded whiteboard tests: Swift Coding Challenges will help walk you through some of the most common problems that get thrown at you during interviews, so you'll be able to practice solutions and ensure you're ready.
The goal is to solve each challenge yourself, but I always provide hints if you need them, as well as complete solutions and explanations so you always learn something new.
Perfect for coding clubs and book groups
If you run a Swift meetup or book group, Swift Coding Challenges makes for ideal reading, encouraging discussion, team work, and solution engineering. The book is structured so that each problem is presented in isolation, so you can pick out particular challenges easily and work through them together.
Learn with solutions
Each challenge is problem presented to you as a simple requirement, just like you would get at a job interview. For example one of the easier ones is, “write a method that returns true if two strings contain the same characters in any order.”
You're then given some example input and output, so you can write test cases. In this example, you'd be given something like "the strings 'abc' and 'cba' should return true, but 'dog' and 'cat' should return false."
And that's it: you need to write code to solve the challenge. If you get stuck, I provide hints that help point you in the right direction. Ideally you don't need these, but they can help if you struggle with particular problems.
Finally, every challenge comes with a complete solution, complete with explanation of how it works so you can compare your code against mine. So if you beat the challenge you can check to make sure your code was optimal, but even if you didn't manage to finish you'll still be able to learn and do better next time.
Test your skills
Every challenge is graded from easy to hard, then grouped into chapters such as Algorithms, Files, Lists, Strings, and more. This means you can focus your efforts wherever you think you're weakest, then start at the beginning to find your skill level.
The book comes with 64 challenges in total, including these:
- Given two strings, write a function that returns true if all letters are unique.
- Make a version of the min() method that returns the three smallest numbers in an array.
- Write an implementation of quicksort for arrays.
- Recreate the built-in map() method for collections.
- Write a function that returns the frequency of a word in an input file.
- Given a Tic-Tac-Toe board, write a function that returns true if either player has won the game.
- Write a function that accepts a binary tree and returns true if it's balanced.
- Given a string with no duplicate characters, write a function that returns an array containing all letter permutations.
- Write a function that accepts an integer array and returns its median value.
- Write a function that accepts a linked list that loops back to itself, and returns the item at the start of the loop.
And that's just a sample – the full book is packed with challenges at all difficulty levels, complete with hints and solutions.
BONUS: You get 90 "Be the compiler" test questions that present you with source code and ask you to figure out what it does. Each answer comes with an explanation so you learn as you go, and the tests are split across three levels so there's something for everyone.
Give your coding brain the exercise it deserves!
Download a free sample!
What you get
The book is delivered as ePub, PDF, Kindle Mobi, and HTML, all without DRM.
The Hacking with Swift guarantee
We want everyone to be happy with all the Hacking with Swift courses they buy, both now and in the future, which is why all our books come with free lifetime Swift updates and free bonus content with our Frequent Flyer Club, and we also encourage folks to join our Slack community to help solve problems.
However, if you aren't happy with a course you bought from us, we offer a 30-day No Questions Asked refund policy. This applies to all books and video courses purchased through Gumroad, which is our primary distributor. So, if you aren't happy with your purchase, if you changed your mind, or if you just bought the wrong thing by accident, we can refund your purchase up to 30 days after it was made.
- The whole book is written for Swift 5.1.
- There's no DRM in any part of the book.
- Anything else? Tweet me @twostraws, or email firstname.lastname@example.org.
We charged your card and sent you a receipt
You'll need an account to access this in our app. Please create a password to continue.
Download from the App Store or text yourself a link to the app
Good news! Since you already have a Gumroad account, it's also been added to your library.