Timeline for Advent of Code 2017, Day 8 - Performing simple instructions
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 15, 2017 at 8:40 | comment | added | Sebastian Stern | @Quuxplusone No, the code would stay the same, it already allows the use of register names for operands. value(int) will return the value, but value(string) will return the current value of the register with this name. The is_int function is just a helper to distinguish between those too cases in value() and will of course only return True, wenn the x is an int. | |
| Dec 14, 2017 at 19:11 | comment | added | Quuxplusone | Ah, planning for future expansion. Makes sense. But were you really planning a future expansion where the function is_int(x) would return True for values of x that were not ints, but rather, register names? That sounds like your current code is redundant but your future code is actively confusing! | |
| Dec 14, 2017 at 8:53 | vote | accept | Sebastian Stern | ||
| Dec 14, 2017 at 8:43 | comment | added | Sebastian Stern | @Quuxplusone Yes, I assume every input is correct. But I also planned for a change where the operations not only can take integers but also the name of a register. So the point of my is_int function was so simplify the usage of value(). I wanted a function where I can input a string or and int and getting back the value of the register matching the string or the intvalue itself. | |
| Dec 13, 2017 at 23:40 | history | tweeted | twitter.com/StackCodeReview/status/941090401976451072 | ||
| Dec 13, 2017 at 21:15 | answer | added | Jared Goguen | timeline score: 5 | |
| Dec 13, 2017 at 18:40 | comment | added | Quuxplusone | You might want to add some explanation about your error-handling strategy. Are you trying to have robust (meaningful) behavior for ill-formed input? or just assume that the input will always match the stated grammar? If the latter, your is_int function is pointless (just cast to int); and it doesn't make sense to use re.search over re.match; and probably a bunch of other stuff. | |
| Dec 13, 2017 at 16:35 | answer | added | aghast | timeline score: 10 | |
| Dec 13, 2017 at 14:28 | answer | added | alecxe | timeline score: 13 | |
| Dec 13, 2017 at 14:11 | history | asked | Sebastian Stern | CC BY-SA 3.0 |