It's the most Wonderful Time Of The Year. Time to spend with Family and Friends spend on Swift coding challenge fun!
Every December, Eric Wastl publishes Advent of Code, a fun set of coding exercises. One challenge is posted each day from December 1st to December 2512th [1]. The challenges start out easy and increase in difficulty. Here’s the first exercise from last year for example.
You can use whatever programming language and techniques you like to complete the exercises, but of course, we use Swift! Participating is a great way to sharpen your Swift skills and have a little fun with the community.
Create an Xcode project (Command Line Tool is fine), Swift Package or clone the starter project
a. if your repo is public, make sure to exclude the input data from version control
Create an account at Advent of Code (required to use the leaderboard)
Every day (or as often as you prefer), attempt the challenge using Swift!
The leaderboard will automatically update to show who has completed the challenge and provide a score based on how long it took you. You can always ignore the score of course - it’s just for fun!
We'd encourage you to include a link to your GitHub account where you can post your solution. It’s really neat to see how everyone attempts each day’s challenge: we learn new things about how others use the Swift language, and you can pick up some great tips and techniques from studying others' work.
Look forward to seeing you online!
This year the number of challenges changed from 25 to 12. Meaning that the event will run until mid-december instead of Christmas Day. ↩︎
Thanks for sharing - this looks great and glad you link to VS Code Swift too in the starter project - though looks like it is the deprecated extension, rather than the newer one. Would it be possible to update to https://marketplace.visualstudio.com/items?itemName=swiftlang.swift-vscode
Never been so grateful for Slices and their shared indexing, which I've previously been irritated by. I take it all back. I'm guessing it's not fast but it does get it done!
var found = ""
var tapeHead = valuesString.startIndex
for i in stride(from: cellCount, to: 0, by: -1) {
let currentSlice = Slice(base: valuesString, bounds: tapeHead..<valuesString.index(valuesString.endIndex, offsetBy: -i+1))
let max = currentSlice.max()!
let maxIndex = currentSlice.firstIndex(of: max)!
found.append(max)
tapeHead = valuesString.index(after: maxIndex) //so fancy that this works.
}