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
chutwig
May 28, 2001

BURLAP SATCHEL OF CRACKERJACKS

On it! I'm always indecisive about whether I want to use these as opportunities to try to work with a new programming language or not. Usually I start with trying to write it in [Flavor Of The Week], bang my head on the desk for an hour, then give up and write it in Python in 5 minutes.

Adbot
ADBOT LOVES YOU

chutwig
May 28, 2001

BURLAP SATCHEL OF CRACKERJACKS

Day 5: REGULAR EXPRESSIONS :arghfist::downs:

chutwig
May 28, 2001

BURLAP SATCHEL OF CRACKERJACKS

Hughmoris posted:

I've looked at it every which way but I'm clueless on how to go about solving Day 4.
*I'm trying to solve this using Perl 6.

Here is how I solved it in Python: https://github.com/erhudy/adventofcode-solutions/blob/master/problem4.py

Basically you need to concatenate the given key to the string form of a monotonically increasing integer, hash it with whatever MD5 function Perl 6 provides that will give you back a string, and check the start of the string for "00000". If not, increment the integer and try again. E.g., if your key is "abcdef", you would MD5 hash "abcdef0", check the hex output for a start of "00000", then try "abcdef1", "abcdef2", and so forth.

Googling around, it looks like actually doing the hashing in Perl 6 might be a pain. You can shell out and use md5/md5sum (just be sure to strip newlines):
code:
In [3]: hashlib.md5(b'blah').hexdigest()
Out[3]: '6f1ed002ab5595859014ebf0951522d9'
code:
$ echo -n "blah" | md5   
6f1ed002ab5595859014ebf0951522d9

chutwig fucked around with this message at 04:04 on Dec 6, 2015

chutwig
May 28, 2001

BURLAP SATCHEL OF CRACKERJACKS

Finally had time to return to the problems after a busy December and restart all the way back at problem 7. Having it laid bare that I'm a systems programmer with little knowledge of algorithms is teeth-gritting sometimes, but that makes it all the more gratifying when I get the solution.

chutwig
May 28, 2001

BURLAP SATCHEL OF CRACKERJACKS

Volguus posted:

Welcome, you're gonna have a lot of fun (until Day 19, drat that day). But, I'm just curious, what does "systems programmer with little knowledge of algorithms" means? From what I know, systems programming still is programming (with a different focus), where algorithms are just as prevalent and as important (if not more so) than application programming.

Sorry, I don't mean systems like low level C/assembly guy. I mean I'm the sysadmin who knows Python who winds up gluing other projects together for deployments, monitoring, that kind of stuff. Describing it as "systems programming" was not the right choice of words.

chutwig fucked around with this message at 03:08 on Dec 28, 2015

  • Locked thread