Post AQCiTIML7G91rnAnYW by JDPilley@twit.social
(DIR) More posts by JDPilley@twit.social
(DIR) Post #AQCaXGqLtY1Kgqb12e by leo@twit.social
2022-12-02T16:43:12Z
0 likes, 0 repeats
I solved it, as most people did, with a lookup table. But after thinking about it overnight I realize I could make everything much simpler by converting ABC and XYZ to 0 1 2 and doing the math. It's really just a one-liner. But by sticking with the letters I missed the numeric relationships between the moves. The 0 3 6 scoring should have been a clue. I'm thinking that this is a foreshadowing of a future problem that will be less tractable to look up tables.
(DIR) Post #AQCauEurE7jxNBeilU by tomasveneny@mastodon.social
2022-12-02T16:47:21Z
0 likes, 0 repeats
@leo I solved similar way ... it was a little bit harder for thinking but it works lolbtw https://github.com/onei2l/adventofcode_php/blob/master/02/index.php
(DIR) Post #AQCbCwowjGGOkloNbE by prawn@twit.social
2022-12-02T16:50:44Z
0 likes, 0 repeats
@leo I used a hash lookup because of the foreshadowing of future use cases
(DIR) Post #AQCdZiSaUHRImdL196 by glowrocks@mastodon.social
2022-12-02T17:17:16Z
0 likes, 0 repeats
@leo fwiw, I used a case statement w/9 choices. But, this one did seem easy; easier than the first to me, and I think you may be right: it's a setup for a future, harder problem.
(DIR) Post #AQCexAWgP8h6RY064m by sukima@twit.social
2022-12-02T17:32:24Z
0 likes, 0 repeats
@leo I was worried my brain would loose orientation if I converted everything to numbers so I made classes and a factory method to pick which class. (Strategy pattern). Verbose but least I had clear intention revealing names for everything.
(DIR) Post #AQCiTIML7G91rnAnYW by JDPilley@twit.social
2022-12-02T18:12:06Z
0 likes, 0 repeats
@leo I want to learn to code. Are there any books or videos you’d recommend to learn C++?
(DIR) Post #AQCvcozwQysV6WZN32 by jake@fediverse.jarv.is
2022-12-02T20:39:24Z
0 likes, 0 repeats
@leo thanks for the reminder, I really need to set an alarm. 😂
(DIR) Post #AQDDm8BeG4lGOldNA0 by mabs@aus.social
2022-12-03T00:02:49Z
0 likes, 0 repeats
@leo That's pretty much how I ended up solving it, and using modulus. I'm wondering if a future problem can be solved using bitfields.