MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/3uyl7s/daily_programming_puzzles_at_advent_of_code/cxj0rds/?context=3
r/programming • u/Aneurysm9 • Dec 01 '15
179 comments sorted by
View all comments
Show parent comment
2
I did
$ perl -E 'for(split//,shift){$x+=/\(/?1:-1};END{say$x}' '()()'
and expanded to
$ perl -E 'for(split//,shift){$i++;$x+=/\(/?1:-1;if($x<0){say$i}};END{say$x}' '()()'
for part 2.
2 u/Aneurysm9 Dec 01 '15 apparently this works for part 1 tooperl -nE 'print tr/(//-tr/)//' input
apparently this works for part 1 too
perl -nE 'print tr/(//-tr/)//' input
View all comments
Show parent comment
2
u/mus1Kk Dec 01 '15
I did
and expanded to
for part 2.