Why don't you use if checksum[5].isdigit() and "{}{}".format(stuff, other_stuff)?
I think I don't use isdigit because I just don't like such explicit input validation. It feels really tedious to me for some reason. As for new style formatting, I'm just used to old style formatting.
Ok, seems to be working now. I think it was the change from checking for a ValueError to the isdigit. There shouldn't be any difference, though... Maybe the location of the continue statement was behaving differently than I expected.
Ok, seems to be working now. I think it was the change from checking for a ValueError to the isdigit. There shouldn't be any difference, though... Maybe the location of the continue statement was behaving differently than I expected.
If the "continue" happens, index += 1 doesn't happen, so that would be an infinite loop.
Ok, seems to be working now. I think it was the change from checking for a ValueError to the isdigit. There shouldn't be any difference, though... Maybe the location of the continue statement was behaving differently than I expected.
If the "continue" happens, index += 1 doesn't happen, so that would be an infinite loop.
My regex are your regex except the ABA one has an extra wrapper of () and incremented backreferences so I can use groups(1) to get the aba string without having to construct it from parts. I had to go back and add the positive lookahead because my first submission rejected overlaps, which we didn't have to worry about for ABBA.
Day 8 was fun! I only had to add one line of code for the second part because I already had a display method for debugging. A deque might be more efficient, I suppose.
My regex are your regex except the ABA one has an extra wrapper of () and incremented backreferences so I can use groups(1) to get the aba string without having to construct it from parts. I had to go back and add the positive lookahead because my first submission rejected overlaps, which we didn't have to worry about for ABBA.
Day 8 was fun! I only had to add one line of code for the second part because I already had a display method for debugging. A deque might be more efficient, I suppose.
I also thought about using a deque because it comes with a rotation function builtin, but I just used the old chop and swap instead.
Anyone know any good resources for starting to build compilers or open source projects that wouldn't be too difficult to contribute to? Thoroughly enjoyed my compilers course and would love to continue building them. They combine all my favorite aspects of computing into one giant, horrible to debug package
Yeah, I know the feeling, I still haven't done it because of a few other commitments, I was thinking a dynamic programming solution with a list of changes and providing the min() of the recursive call to moving 2 chips, 2 generators or a chip and a generator, and for each loop through all possible combinations on that floor.
Alternatively could also be reduced to a BFS or IDDLS however it's not working in my head clearly by approaching it in a newish language. Each adjacent edge would obviously be a logical possible move and each node a state for all 4 floors to be at.
the logical check at each floor at the start of the recursion or loop would be to check (after adding elevator contents to the floor) if there are any microchips without corresponding generators and if so, if there are any generators with no corresponding microchips then that should fail.
Comments
https://github.com/Apreche/advent2016
if checksum[5].isdigit()
and"{}{}".format(stuff, other_stuff)
?isdigit
.I'm onto day 6. It's looking easy so far.
https://gist.github.com/lackofcheese/32c4ecf4c0680ffdd758442382e18ffc
- Jamie Zawinski
()
and incremented backreferences so I can usegroups(1)
to get the aba string without having to construct it from parts. I had to go back and add the positive lookahead because my first submission rejected overlaps, which we didn't have to worry about for ABBA.Day 8 was fun! I only had to add one line of code for the second part because I already had a display method for debugging. A deque might be more efficient, I suppose.
collections.defaultdict
.Thoroughly enjoyed my compilers course and would love to continue building them. They combine all my favorite aspects of computing into one giant, horrible to debug package
FIGHT FIGHT FIGHT
Alternatively could also be reduced to a BFS or IDDLS however it's not working in my head clearly by approaching it in a newish language. Each adjacent edge would obviously be a logical possible move and each node a state for all 4 floors to be at.
the logical check at each floor at the start of the recursion or loop would be to check (after adding elevator contents to the floor) if there are any microchips without corresponding generators and if so, if there are any generators with no corresponding microchips then that should fail.