Tag Archives: puzzle

Advent of Code: holiday-themed puzzles

Coding isn’t scary — Have fun learning or practicing your skills.

Being able to write computer code is an increasingly valuable skill that isn’t commonly taught in primary education, or a part of the curriculum for many undergraduate majors. Similarly, coding/computer programming is nearly absent from the curriculum here at Sackler. There seem to be three dominant reasons for this: coding isn’t always seen as being applicable, code itself can be intimidating, and there isn’t someone qualified to teach the subject. However, being ignorant of coding puts us, individually and as an institution, at a competitive disadvantage, and unnecessarily so. Learning how to code isn’t scary or even particularly difficult. Sure, code can be complex, but no one starts learning how to code by diving into the most difficult examples. The principles of coding are no more complex than basic lab protocols that we here at Sackler are at least comfortable with, if not masters at executing.

This is the introduction to a series of short articles about the basics of coding that Sackler students should understand, which will begin with the next issue of the InSight. For now, I want to highlight a series of holiday-themed coding puzzles to keep everyone occupied over the holidays.

Christmas tree rendered with text
Advent of Code, day 6.

A software engineer named Eric Wastl has put together a series of coding challenges called Advent of Code at adventofcode.com. One two-part puzzle is revealed each day just after midnight. The puzzle takes the form of a word problem, and provides you with input to feed into the code you write to solve the problem. The answer to the puzzle, the output of your code, can be submitted to the site, which tells you if you’re right, too high, or too low. If you’re right, you earn as star for that part of that part of the puzzle, which lights up one level of a Christmas tree rendered in text. Earning the first star of each day changes the corresponding level of the tree from gray to green, while earning the second lights up the “ornaments”. You can use any programming language you like, including Python, R, and PHP, which some students may already be familiar with.

Interested? The first day’s puzzle is below; visit adventofcode.com to create your account and get your own input:

Santa is trying to deliver presents in a large apartment building, but he can’t find the right floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) and then follows the instructions one character at a time.

An opening parenthesis, (, means he should go up one floor, and a closing parenthesis, ), means he should go down one floor.

The apartment building is very tall, and the basement is very deep; he will never find the top or bottom floors.

For example:

(()) and ()() both result in floor 0.

((( and (()(()( both result in floor 3.

))((((( also results in floor 3.

()) and ))( both result in floor -1 (the first basement level).

))) and )())()) both result in floor -3.

To what floor do the instructions take Santa?