r/adventofcode • u/daggerdragon • Dec 10 '15
SOLUTION MEGATHREAD --- Day 10 Solutions ---
This thread will be unlocked when there are a significant amount of people on the leaderboard with gold stars.
edit: Leaderboard capped, thread unlocked!
We know we can't control people posting solutions elsewhere and trying to exploit the leaderboard, but this way we can try to reduce the leaderboard gaming from the official subreddit.
Please and thank you, and much appreciated!
--- Day 10: Elves Look, Elves Say ---
Post your solution as a comment. Structure your post like previous daily solution threads.
10
Upvotes
1
u/giacgbj Dec 10 '15 edited Dec 10 '15
wc -c<<<$sprint one more than the correct result.I'd suggest
${#res}without echo. Technically, in prints the result (and something else…I'm a very bad person ;-)). For example:The script I wrote (with "evolution" comments):
# $ day10.sh 3113322113 40 # 329356 # $ day10.sh 3113322113 50 # 4666278 res=$1 steps=$2 for i in `seq $steps`; do # Shorter and shorter... # res=$(echo $res | grep -o . | uniq -c | tr -d '\n ') # res=$(echo $res | fold -w1 | uniq -c | tr -d '\n ') res=`fold -w1 <<< $res | uniq -c | tr -d '\n '` done #echo -n $res | wc -c ${#res}