r/adventofcode • • Dec 04 '16

SOLUTION MEGATHREAD --- 2016 Day 4 Solutions ---

--- Day 4: Security Through Obscurity ---

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


CONSTRUCTING ADDITIONAL PYLONS 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!

17 Upvotes

168 comments sorted by

View all comments

Show parent comment

1

u/uniquefox314 Dec 04 '16

I really need to start getting better with linq and regex, it's looks way better to use regex than to use the ascii values to complete operations :p

1

u/WildCardJoker Dec 05 '16

I didn't use regex much last year.

Previously, I would have done something like this to get the checksum:

var index = input.IndexOf("[")
var checksum = input.Substring(index,input.Length-index-1)

Or I would have split the input into an array using the - character as a separator.

Regex is certainly easier :)

I had a lot of help from Stack Overflow as well.