Last active
December 8, 2015 21:55
-
-
Save mcreenan/ed9459d2dc5339c4ea37 to your computer and use it in GitHub Desktop.
Advent of Code - Day 8 - Perl6 Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
# Part 1 | |
say [+] 'input'.IO.lines.map: { (m:g/ \\x<[a..f0..9]>**2 /.list.elems * 3) + (m:g/ \\(\"|\\) /.list.elems) + 2 } | |
# Part 2 | |
say [+] 'input'.IO.lines.map: { (m:g/ \\x<[a..f0..9]>**2 /.list.elems) + (m:g/ \\ (\"|\\) /.list.elems * 2) + 4 } | |
# Things I learned: | |
# 1. Using .IO.lines on a filename string to read line-by-line | |
# 2. Regex modifiers go before first / now | |
# 3. Hyper operator for doing reduce operations | |
# 4. Using .list to get group matches | |
# 5. Using .elems to get number of items in list/array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment