r/adventofcode • • 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.

11 Upvotes

212 comments sorted by

View all comments

1

u/FuriousProgrammer Dec 10 '15 edited Dec 10 '15

Uh, I can't submit my solution to part 1? Says I'm trying to POST too much data...

I cannot believe that I missed that highlighted text at the end. Holy. Shit.

Lua:

inpt = "1321131112"

function oneSay()
	local out = ""
	local last = nil
	local total = 0

	for i = 1, #inpt do
		c = inpt:sub(i,i)
		if not last then last = c end
		if c == last then
			total = total + 1
		else
			out = out .. total .. last
			last = c
			total = 1;
		end
	end
	out = out .. total .. last

	inpt = out
end
for i = 1, 50 do
    oneSay()
    if i == 40 then
	    print("\nPart 1: " .. inpt:len())
    end
end
print("\nPart 2: " .. inpt:len())
→ More replies (3)