You are reading a single comment by @Greenbank and its replies. Click here to read the full conversation.
  • Yeah, I just smashed the input strings into a map, e.g.

            p1poss := map[string]int{
                    "A X": 1 + 3, "A Y": 2 + 6, "A Z": 3 + 0,
                    "B X": 1 + 0, "B Y": 2 + 3, "B Z": 3 + 6,
                    "C X": 1 + 6, "C Y": 2 + 0, "C Z": 3 + 3,
            }
    

    Didn't even have to parse/split the incoming string.

  • I thought about make a map of possibilities, ended up doing this:

    def part2(game: list[str, str]) -> int:
        offset = ord("A")
        score_dict = {
            "X": ((ord(game[0]) - offset - 1) % 3) + 1,
            "Y": ord(game[0]) - offset + 4,
            "Z": ((ord(game[0]) - offset + 1) % 3) + 7,
        }
        return score_dict[game[1]]
    

    Probably less readable overall though

About

Avatar for Greenbank @Greenbank started