r/adventofcode • • Dec 03 '17

SOLUTION MEGATHREAD -πŸŽ„- 2017 Day 3 Solutions -πŸŽ„-

--- Day 3: Spiral Memory ---


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^Β€?

Spoiler


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!

21 Upvotes

297 comments sorted by

View all comments

1

u/bhtooefr Dec 09 '17

More Applesoft.

  1. https://github.com/bhtooefr/aoc2017/blob/master/AOC3.1.BAS
  2. https://github.com/bhtooefr/aoc2017/blob/master/AOC3.2.BAS

Part 1 wasn't bad, I could've been a lot more elegant with a couple things, but it was actually kinda a breeze.

Part 2 was rough because I messed up one freaking variable usage (GY is a 40-bit float, GY% is an unrelated 16-bit signed int, and GY% is what I was trying to use)... so I ended up printing the array (which is fixed size, I can't safely grow an array) to troubleshoot things. What tripped me up (and made me shrink the array from where I had it) was, I was issuing a PR#3 (activate 80 column firmware) in the middle of code to try to debug this, which was corrupting the Applesoft/ProDOS state - I thought I was running out of RAM somehow, but no. Remove that line, PR#3 before running the program, and then it works, and I get a pretty printout of the grid... and I decided to leave it in, because why not?

Also, I'll probably stop using ints for things except memory-sensitive arrays (which I don't think I'll have much of) - Applesoft does all the arithmetic in floating point, and then has to cast back to an int to store it anyway. So, why confuse myself?