Advent of Code Solutions Thread: Day Two

Only shitty solutions allowed

38
Jump in the discussion.

No email address required.

I'm bringing my latop with me to work, I'm not solving another night on my phone and debugging on my desktop. code is shit and it's what OP asked for

func One() int {
	var total_sum, outcome int

	fp, _ := os.Open("two.txt")
	defer fp.Close()
	rd := bufio.NewScanner(fp)

	for i := 0; rd.Scan(); i++ {
		var a, b, play int
		round := strings.Split(rd.Text(), " ")

		for i, v := range round {
			switch v {
			// rock
			case "A", "X":
				play = 1
			//paper
			case "B", "Y":
				play = 2
			//scissors
			case "C", "Z":
				play = 3
			}

			if i%2 == 0 {
				b = play
			} else {
				if play == 2 {
					a = b
				} else if play == 1 {
					switch b {
					case 3:
						a = 2
					case 2:
						a = 1
					case 1:
						a = 3
					}
				} else {
					switch b {
					case 3:
						a = 1
					case 2:
						a = 3
					case 1:
						a = 2
					}
				}
			}
		}

		if (a == 1b == 2) {
			outcome = 6
		} else if a == b {
			outcome = 3
		} else {
			outcome = 0
		}

		total_sum = total_sum + (a + outcome)
	}

	return total_sum
}
Jump in the discussion.

No email address required.

you're fricking bananas if you think I'm reading all that, take my downmarsey and shut up idiot

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.