LOADING: An error occurred. Update Chrome, try Firefox, or visit this post for more details.

⚠️Reddit changed how removals work, which breaks Reveddit's website. Install the extension to track removed content:Add to chromeAdd to firefoxWhat changed?
✖︎
about reveddit
⚙F.A.Q.add-ons
r/
status
copy sharelink
[+] show filters
103
SOLUTION MEGATHREAD-🎄- 2022 Day 2 Solutions -🎄-(self.adventofcode)
submitted 3 years, 1 month ago* (edited 4 days, 4 hours after) by daggerdragon to /r/adventofcode (134.8k)
1501 commentsredditother-discussionssubreddit-indexmessage modsop-focus

NEW AND NOTEWORTHY

  • All of our rules, FAQs, resources, etc. are in our [community wiki](/r/adve...

... view full text

since 3 years, 1 month ago
1 of 1

Tip Reveddit Real-Time can notify you when your content is removed.

your account history
(check your username's removed content. why?)
Tip Check if your account has any removed comments.
view my removed comments
you are viewing a single comment's thread.
view all comments
[–][deleted]3 points3 years, 1 month ago* (edited 3 days, 4 hours after)

I'm doing different language each day, all solutions here.

Today's Go (dunno why I used named returns instead of just returning the score in part1/2()..):

package main

import (
    "bufio"
    "fmt"
    "log"
    "os"
)

func main() {
    file, err := os.Open("input.txt")
    if err != nil {
        log.Fatal(err)
    }

    var score1, score2 int

    scanner := bufio.NewScanner(file)
    for scanner.Scan() {
        score1 += part1(scanner.Text())
        score2 += part2(scanner.Text())
    }

    if err := scanner.Err(); err != nil {
        log.Fatal(err)
    }

    fmt.Println(score1)
    fmt.Println(score2)
}

func part1(round string) (score int) {
    switch round {
    case "A X":
        score += 4
    case "A Y":
        score += 8
    case "A Z":
        score += 3
    case "B X":
        score += 1
    case "B Y":
        score += 5
    case "B Z":
        score += 9
    case "C X":
        score += 7
    case "C Y":
        score += 2
    case "C Z":
        score += 6
    }
    return
}

func part2(round string) (score int) {
    switch round {
    case "A X":
        score += 3
    case "A Y":
        score += 4
    case "A Z":
        score += 8
    case "B X":
        score += 1
    case "B Y":
        score += 5
    case "B Z":
        score += 9
    case "C X":
        score += 2
    case "C Y":
        score += 6
    case "C Z":
        score += 7
    }
    return
}
permalinkas-of
r/revedditremoved.substack.com
🚨 NEWS 🚨
✖︎

Important: Reddit Changed How Removals Work

A recent Reddit update makes mod-removed content disappear from profile pages, which breaks Reveddit's website.

Install the browser extension to receive removal alerts.

Add to chromeAdd to firefox

What changed?

r/revedditremoved.substack.com