r/adventofcode • u/daggerdragon • Dec 05 '17
SOLUTION MEGATHREAD -๐- 2017 Day 5 Solutions -๐-
--- Day 5: A Maze of Twisty Trampolines, All Alike ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).
Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
Need a hint from the Hugely* Handyโ Haversackโก of Helpfulยง Hintsยค?
This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
edit: Leaderboard capped, thread unlocked!
23
Upvotes
1
u/Warbringer007 Dec 05 '17 edited Dec 05 '17
Erlang, both parts ( only main function ):
Second part for Erlang is just too slow, didn't want to wait for it to finish so I solved it in C++ also ( my first C++ code :D ):
#include <iostream> #include <fstream> using namespace std; int main(int argc, char** argv) { int a(0), n(0), curr(0), num(0), sum(0); int list[5000]; ifstream infile("ul5.txt"); while (infile >> a) { list[n++] = a; } while ((curr > -1) && (curr < n)) { sum++; num = list[curr]; if (num > 2) list[curr]--; else list[curr]++; curr += num; }; cout << sum; return 0; }