Follow

Advent of Code Day 2 - partial idea for solution, spoiler-ish 

Going to call it a night. Didn’t finish day 2’s advent of code challenge, but did study for my calc final.

So for I’m really liking my approach and it’s giving me practice using header files and taking command line arguments.

I’m going to take advantage of the fact that alphabetical characters correspond to a number in C which should allow me to subtract the beginning of the possible moves from the move played to get the score for that move.

So I’m thinking ‘A’ - ‘A’ will be 0. Then I can just add 1 to get the “value” of that move. 1 for rock, 2 for paper, 3 for scissors. You can do the same thing for X, Y and Z if you have the beginning of the move set be X, then ‘Z’ - ‘X’ would equal 2 and then add 1 to get 3.

Advent of Code Day 2 - partial idea for solution, spoiler-ish 

@derickflorian Yes, you have a good idea I think. If you check an ASCII chart ( en.wikipedia.org/wiki/ASCII ), you'll see the character before 'A' is '@' so you could use that to save the need to add the one after (not that that is wrong, just a little trick ;) As fun as the AoC challenges are, the exams have to come first... good luck with them!

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.