r/adventofcode • • Dec 07 '16

SOLUTION MEGATHREAD --- 2016 Day 7 Solutions ---

From all of us at #AoC Ops, we hope you're having a very merry time with these puzzles so far. If you think they've been easy, well, now we're gonna kick this up a notch. Or five. The Easter Bunny ain't no Bond villain - he's not going to monologue at you until you can miraculously escape and save the day!

Show this overgrown furball what you've got!


--- Day 7: Internet Protocol Version 7 ---

Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).


ALWAYS DIGGING STRAIGHT DOWN IS MANDATORY [?]

This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked!

14 Upvotes

180 comments sorted by

View all comments

Show parent comment

5

u/Hwestaa Dec 07 '16

Can you post the program that you (I hope) used to generate that monstrosity? And for part 2?

6

u/askalski Dec 07 '16

This is the generator I used to make Part 2. It writes an extra | at the end that needs to be removed manually. I didn't keep the code for Part 1, but it's just a simpler version of this (all it does is write out abba|acca|adda|....)

#! /usr/bin/env perl

use strict;
use warnings;

for $a ('a'..'z') {
    for $b ('a'..'z') {
        next if $a eq $b;
        print "$a$b$a\[a-z]*(?:\\[[a-z]*][a-z]*)*?\\[[a-z]*?$b$a$b|";
        print "$a$b$a\[a-z]*](?:[a-z]*\\[[a-z]*])*?[a-z]*?$b$a$b|";
    }
}