2018 Advent of Code


#1

Anyone else doing the 2018 Advent of Code?

If you don’t know, the advent of code is:

Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university coursework, practice problems, or to challenge each other.

https://adventofcode.com/

In general I hate speed contests, interviews, companies, universities, practicing and being challenged, but I’m giving it a go this year!


#2

I did end up finishing day 1 on time, the first part was e-z, the second part definitely tripped me up. I’m trying to specifically use functional programming, so not looping through it in a traditional manner took some… understanding?


#3

Not to mention a lot of stack space.


#4

Here is my answer to Day 1 part 2 , I tried to do it obscurely for fun

<?php

$changes = array_map("intval",array_filter(explode("\n", file_get_contents("freqlist.dat"))));

$sum = 0;
$found = [];
$answer = false;

while($answer === false) {
    array_map(function($a) use (&$sum, &$found, &$answer) { 
        return ($answer === false && isset($found[$sum += $a]) && $answer = $sum) || $found[$sum] = false; 
    }, $changes);
}

print "Answer: $answer\n";


#5

Just finished day 2! Second one tripped me up. @Draco when you do it there’s a really nice PHP function that’ll help :slight_smile:


#6

Yup, there sure is … I don’t use that function often enough.
Looking through all the php functions, there are alot I don’t use.

Day 2 complete… working on Day 3


#7

Completed Day 3 … getting more complex …

I thought about using some sort of image functions doing this one.


#8

Yes, I’m doing mine in Ruby. Can anyone DM me their input for Day 2 Part 1?

My code works for the example, but for my input I’m getting the wrong checksum. I’d like to run your input through my script and report back what checksum I get. Thanks!


#9

The input is downloadable on the site … it is just a text file.


#10

So burned up from programming all day at work, I literally cannot focus enough to finish todays… :\

Damn.