#CodeCarols: The geeky way to celebrate the season

Pluralsight
Pluralsight
Published in
2 min readDec 22, 2017

‘Tis the season of non-stop Christmas music. And while there’s nothing wrong with the classic fare, we wondered what our favorite songs would look like reinterpreted through code. The Pluralsight author community answered the call, and #CodeCarols were born—here are three of our favorites.

Santa Claus is Coming to Town

def santa(children):
good_children = [child for child in children if child.behaviour == ‘nice’]
# Check twice
good_children_2 = [child for child in children if child.behaviour == ‘nice’]
if good_children == good_children_2:
come_to_town()
else:
raise BadChildrenException()

Anthony Shaw included a disclaimer with his carol:

This code snippet would only match correctly in Python 3.6, where the children dictionary would be an ordered dictionary/attrs by default.

Let It Snow! Let It Snow! Let It Snow!

data class Weather(val isOutSide: Boolean = true, val isFrightful:Boolean = true)
data class Fire(val isSoDelightful:Boolean = true)
data class Place(val togo:Boolean = false)
fun Place.snow() { println(“:snowflake::snowflake::snowflake::snowflake::snowflake::snowflake::snowflake:“) }
fun main(args: Array<String>) {
val weather = Weather()
val fire = Fire()
val place = Place()

if((weather.isOutSide && weather.isFrightful)
&& fire.isSoDelightful
&& !place.togo)
{
place.let{
it.snow()
it.snow()
it.snow()
}
}
}

Written in Kotlin by Michael Yotive.

Rockin’ Around the Christmas Tree

Rockin around the Binary Search Tree
Have a Happy Holiday
Everyone sorted merrily
In a O(n log n) way

Though it’s not technically code, Dustin Schultz wrote this verse as a clever nod to all those who understand computer science.

Are you inspired to create your own carol? Tweet it with #CodeCarols and you might find a bonus present under the tree. 🙂

--

--

Pluralsight
Pluralsight

We are *the* technology learning platform, dedicated to helping teams create the future.