Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer
I've been solving these with Haskell. Mostly it's been going well, but my Day 6 solution was very inefficient because I implemented it with the Data.Array module and couldn't figure out how to only run through the indices that were actually changed with the available functions, so I ended up updating the entire array every time. I probably should've used a mutable 2D array of some sort instead, but my initial solution was barely fast enough to be acceptable so I didn't bother.

Day 7 tripped me up repeatedly because I didn't understand the question correctly:
- At first I thought a wire would always already have a signal at the time it's used to provide a signal for another wire, mostly because that was the case in the example. Actually looking at the input cleared up that misconception.
- Then I for some reason got it into my head that if a wire doesn't have a signal when it's used it should be treated as having the value 0. I pulled this out of thin air, and it was obviously wrong.
- At last I realized that you're supposed to go through the list repeatedly until all the signals are turned on (or build some sort of expression tree by going backwards, I guess), so I changed up my algorithm and got a plausible result, but it was still wrong.
- Then I spent another half hour or so until I finally realized I had been rotating the bits instead of shifting them. :v:

I found Day 8 to be simpler in comparison. I used the very awesome Parsec library to parse the strings and got the right result pretty quickly. Using regex or even just simple string matching would probably be just as easy, but they're not as cool as Parsec.

Adbot
ADBOT LOVES YOU

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer
I like how you're giving us all these NP-complete problems but making the datasets juuust small enough that you can brute force them. :shobon:

  • Locked thread