
Write a function that accepts a String as its only parameter, and returns true if the string has
only unique letters, taking letter case into account.
Write a function that accepts a String as its only parameter, and returns true if the string
reads the same when reversed, ignoring case.
Write a function that accepts two String parameters, and returns true if they contain the same characters in any order taking into account letter case.
Write your own version of the contains() method on String that ignores letter case, and
without using the existing contains() method.
Write a function that accepts a string, and returns how many times a specific character appears,
taking case into account.
Write a function that accepts a string as its input, and returns the same string just with
duplicate letters removed.
Write a function that returns a string with any consecutive spaces replaced with a single space.
Write a function that accepts two strings, and returns true if one string is rotation of the other,
taking letter case into account.
Write a function that returns true if it is given a string that is an English pangram, ignoring
letter case.
Given a string in English, return a tuple containing the number of vowels and consonants.
Write a function that accepts two strings, and returns true if they are identical in length but
have no more than three different letters, taking case and string order into account.
Write a function that accepts a string of words with a similar prefix, separated by spaces, and
returns the longest substring that prefixes all words.
Write a function that accepts a string as input, then returns how often each letter is repeated in
a single run, taking case into account.
Write a function that prints all possible permutations of a given input string.
Write a function that returns a string with each of its words reversed but in the original order,
without using a loop.
Write a function that counts from 1 through 100, and prints “Fizz” if the counter is evenly divisible by 3, “Buzz” if it’s evenly divisible by 5, “Fizz Buzz” if it’s even divisible by three and five, or the counter number for all other cases.
Write a function that accepts positive minimum and maximum integers, and returns a random
number between those two bounds, inclusive.
Create a function that accepts positive two integers, and raises the first to the power of the
second.
Swap two positive variable integers, a and b, without using a temporary variable.
Write a function that accepts an integer as its parameter and returns true if the number is prime.
Create a function that accepts any positive integer and returns the next highest and next lowest number that has the same number of ones in its binary representation. If either number is not possible, return nil for it.
Create a function that accepts an unsigned 8-bit integer and returns its binary reverse, padded
so that it holds precisely eight binary digits.
Write a function that accepts a string and returns true if it contains only numbers, i.e. the digits
0 through 9.
Given a string that contains both letters and numbers, write a function that pulls out all the
numbers then returns their sum.
Write a function that returns the square root of a positive integer, rounded down to the nearest
integer, without using sqrt().
Create a function that subtracts one positive integer from another, without using - .
Write a function that accepts a filename on disk, then prints its last N lines in reverse order, all
on a single line separated by commas.
Write a logging function that accepts accepts a path to a log file on disk as well as a new log message. Your function should open the log file (or create it if it does not already exist), then append the new message to the log along with the current time and date.
Write a function that returns a URL to the user’s documents directory.
Write a function that accepts a path to a directory and returns an array of all JPEGs that have
been created in the last 48 hours.
Write a function that accepts two paths: the first should point to a directory to copy, and the second should be where the directory should be copied to. Return true if the directory and all its contents were copied successfully; false if the copy failed, or the user specified something other than a directory.
Write a function that accepts a filename on disk, loads it into a string, then returns the frequency of a word in that string, taking letter case into account. How you define “word” is worth considering carefully.
Write a function that accepts the name of a directory to scan, and returns an array of filenames that appear more than once in that directory or any of its subdirectories. Your function should scan all subdirectories, including subdirectories of subdirectories.
Write a function that accepts the name of a directory to scan, and returns an array containing
the name of any executable files in there.
Write a function that accepts a path to a directory, then converts to PNGs any JPEGs it finds in there, leaving the originals intact. If any JPEG can’t be converted the function should just quietly continue.
Write a function that accepts accepts a path to a log file on disk, and returns how many lines
start with “[ERROR]”. The log file could be as large as 10GB, but may also not exist.
Write an extension for collections of integers that returns the number of times a specific digit
appears in any of its numbers.
Write an extension for all collections that returns the N smallest elements as an array, sorted
smallest first, where N is an integer parameter.
Extend collections with a function that returns an array of strings sorted by their lengths,
longest first.
Create a function that accepts an array of unsorted numbers from 1 to 100 where zero or more
numbers might be missing, and returns an array of the missing numbers.
Write an extension to collections that accepts an array of Int and returns the median average,
or nil if there are no values.
Write an extension for all collections that reimplements the index(of:) method.
Create a linked list of lowercase English alphabet letters, along with a method that traverses all
nodes and prints their letters on a single line separated by spaces.
Extend your linked list class with a new method that returns the node at the mid point of the
linked list using no more than one loop.
Write a new method for your binary search tree that traverses the tree in order, running a closure on each node.
Write an extension for all collections that reimplements the map() method.
Write an extension for all collections that reimplements the min() method.
Create a new data type that models a double-ended queue using generics, or deque. You should be able to push items to the front or back, pop them from the front or back, and get the number of items.
Write a function that accepts a variadic array of integers and return the sum of all numbers that
appear an even number of times.
Write a function that accepts an array of positive and negative numbers and returns a closed range containing the position of the contiguous positive numbers that sum to the highest value, or nil if nothing were found.
Expand your code from challenge 43 so that it has a reversed() method that returns a copy
of itself in reverse.
Write one function that sums an array of numbers. The array might contain all integers, all
doubles, or all floats.
Your job is to write a function that accepts your linked list as its parameter, and returns the node at the start of the loop, i.e. the one that is linked back to.
Create a binary search tree data structure that can be initialized from an unordered array of
comparable values, then write a method that returns whether the tree is balanced.
Create an extension for arrays that sorts them using the bubble sort algorithm.
Create an extension for arrays that sorts them using the insertion sort algorithm.
Write a function that accepts two values and returns true if they are isomorphic. That is, each
part of the value must map to precisely one other, but that might be itself.
Write a function that accepts a string containing the characters (, [, {, <, >, }, ], and ) in any arrangement and frequency. It should return true if the brackets are opened and closed in the correct order, and if all brackets are closed. Any other input should false.
Create an extension for arrays that sorts them using the quicksort algorithm.
Create a function that detects whether either player has won in a game of Tic-Tac-Toe.
Write a function that returns an array of prime numbers from 2 up to but excluding N, taking
care to be as efficient as possible.
Write a function that accepts an array of CGPoint pairs, and returns an array of the angles
between each point pair. Return the angles in degrees, where 0 or 360 is straight up.
There are M different ways you can place N queens on an NxN chessboard so that none of them are able to capture others. Write a function that calculates them all and prints them to the screen as a visual board layout, and returns the number of solutions it found.
Swift Coding Challenges is produced from the "Hacking with Swift" series of tutorials, which are written and authored by the award winning Swift programmer, Paul Hudson, and these videos were made with his permission
and support. You can always be guaranteed you're learning the latest and greatest Apple technologies in the HWS tutorials. Hacking with Swift is one of the most popular Swift tutorial series online, which uses an approach that teaches you Swift programming incredibly quickly, and you end up with a huge library of finished projects that are yours to develop further, or ship to the App Store. Paul has received high praise from the creator of the Swift language, Chris Lattner, for his outstanding method of teaching, and series of Swift tutorials. And working together with iOS developer Steve DeStefano, the Hacking with Swift series of programming training videos are simply the fastest way to learn how to code in the Apple eco-system.
Note: Section 2 has the Swift 5 update for all the challenges, questions and answers.
Check out all of Paul Hudson's Swift tutorials and books at HackingWithSwift
This course is designed to get you ready for your iOS job interview, and for that whiteboard test. All these challenges are real world examples that you can expect to see in an actual iOS interview. And if your not looking for a job, than these challenges are a great way to level up your current iOS skills, and get a great library of coding solutions for your reference to boot.
You'll be presented with various challenges to solve, and I’ll be helping you along with hints, as well as the solutions and explanations for each of the challenges. I also provide a complete transcript of each lecture (solution included) for you to download as a text file.
And, this course is called Swift Coding Challenges because you will be challenged. There is no learning without struggle, so if you don’t take the time to watch each challenge and try it for yourself in Xcode, you’ll never know how you would have fared.
Note: This course is not for Swift beginners, so you should have at least six months of Swift behind you...preferably a year. If you’ve completed Paul Hudson's Hacking with Swift instructional tutorials at HackingWithSwift dot com, you should to be able to handle the Easy challenges, and some of the Tricky ones. If you’ve completed his Pro Swift, then you should be able to handle most of the Taxing problems too. If you consistently struggle with challenges, then you should definitely watch Paul's Pro Swift videos too. See all his tutorials and books at HackingWithSwift
What will be covered:
Course content from the award winning Swift programmer Paul Hudson's book- Swift Coding Challenges
The latest Swift is used - Swift 5
Prepare for iOS interviews and ace the whiteboard test
Test yourself against your friends and level up your skills
Hints are given in for each challenge to help if you get stuck
Three skill levels: Novice - Intermediate - Senior developer
Solutions are given for all challenges - many challenges will have multiple solutions given
Most challenges can be done in a playground - the rest will use a mac command line project
Deep explanations as to how the code works
All the lectures are downloadable as a text file transcript - for your own coding library
Challenge yourself with Strings - Numbers - Files - Collections - Algorithms
Multiple choice challenges - Novice - Intermediate - Expert levels