r/adventofcode • u/taliriktug • Dec 02 '15
Spoilers Day 2 solutions
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
15
Upvotes
r/adventofcode • u/taliriktug • Dec 02 '15
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
View all comments
Show parent comment
1
u/lukz Dec 02 '15
Your code is probably working, I didn't try it, just had a look at it. You are processing the input one character at a time. That is ok. But it was a good idea for day 1 problem, not so good idea for day 2 problem.
So I would give this hint: can you make a program that does the following? 1. read all characters up to the 'x', put all of them into a string (without the 'x') then convert the string into integer, 2. do the same from the previous position up to the 'x', 3. read all characters from previous position up to the '\n', put them into a string (without the '\n'), convert to integer. Doing it this way may make your program shorter.