RSS
 

Archive for the ‘Advent Of Code’ Category

Advent Of Code 2015: Day 8

09 Dec 2015
CTF: Advent Of Code 2015
Link to challenge: http://adventofcode.com
Date Completed: 09 December 2015

Challenge

Solution

A fairly simple puzzle. My approach was to add up the strings together and use regular expressions to replace special characters with a * character so that the python len function would provide me with the correct result.

Script:

 
2 Comments

Posted in Advent Of Code 2015

 

Advent Of Code 2015: Day 7

08 Dec 2015
CTF: Advent Of Code 2015
Link to challenge: http://adventofcode.com
Date Completed: 07 December 2015

Challenge

Solution

Wow this one was fun! I decided to use Z3Py, a theorem prover module for python. My solution essentially parses each command using regexp and adds the various boolean rules to a solver object. Finally, the theorem solver checks all possible values and prints out the results of every ‘wire’. Determining the answer is then very simple. To solve part 2 I simply changed the value of b in my input.txt to the answer from part a and reran the script.

 
No Comments

Posted in Advent Of Code 2015

 

Advent Of Code 2015: Day 6

06 Dec 2015
CTF: Advent Of Code 2015
Link to challenge: http://adventofcode.com
Date Completed: 06 December 2015

The Challenge

Solution

I split up the solutions for part 1 and part 2. Was almost tempted to go for a numpy and scipy sparse matrix solution but a 1000×1000 matrix is small enough for a dense matrix.

Part 1

Part 2

 
No Comments

Posted in Advent Of Code 2015

 

Advent Of Code 2015: Day 5

05 Dec 2015
CTF: Advent Of Code 2015
Link to challenge: http://adventofcode.com
Date Completed: 05 December 2015

The Challenge

Solution

Another quick and simple Python solution!

 
No Comments

Posted in Advent Of Code 2015

 

Advent Of Code 2015: Day 4

04 Dec 2015
CTF: Advent Of Code 2015
Link to challenge: http://adventofcode.com
Date Completed: 04 December 2015

The Challenge

Solution

Because speed was not an issue in this case, I simply used python again to solve the problem. The script is a little slow taking ~10 seconds to compute the answer in my case. A C/C++ solution would be orders of magnitude faster.

 
No Comments

Posted in Advent Of Code 2015

 

Advent Of Code 2015: Day 3

04 Dec 2015
CTF: Advent Of Code 2015
Link to challenge: http://adventofcode.com
Date Completed: 03/12/2015

The Challenge

Solution

A rather interesting challenge. I wasn’t too happy with my solution but it works.
I split up parts 1 and parts 2 so the code can be read more easily.

Part 1 – Santa Solo Trip

Part 2 – Santa + Robo Santa

I didn’t like the use of the santasTurn boolean here too much but couldn’t think of a nicer way to complete the task (in the 15 minutes before I went to sleep!).

 
No Comments

Posted in Advent Of Code 2015

 

Advent Of Code 2015: Day 2

02 Dec 2015
CTF: Advent Of Code 2015
Link to challenge: http://adventofcode.com
Date Completed: 02/12/2015

The Challenge

Solution

This challenge was very simple. I whipped up a short python script that solves it. The use of sorted to get the second smallest integer is not pretty but insignificant with such small numbers.

 
No Comments

Posted in Advent Of Code 2015

 

Advent Of Code 2015: Day 1

02 Dec 2015
CTF: Advent Of Code 2015
Link to challenge: http://adventofcode.com
Date Completed: 01/12/2015

The Challenge

Solution

Before part 2 of the problem was revealed I decided to tackle the problem using the command line. I cam up with the following command:

We echo the input and remove the ) symbol which leaves only ( and we use wc to count the number of  ( symbols which tells us how many times we went to a higher floor. We then subtract his number from the number of times we went to a lower floor (using bash arithmetic) which gives us our answer.

Part 2 of the problem would be annoying to do on the command line so I decided to write a quick python script to solve it. The solution also solves the first part of the problem (lol).

 
No Comments

Posted in Advent Of Code 2015