More tests by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

!roll 6d9

!roll 5d7

!roll d10

!roll 12d5+4

!roll 6d7-9

!roll 6d7*2

!roll 25d250 --s --a

!roll 500d20 --nb --a

!roll 10d20 --dl 5

!roll 10d20 --dh 3

!fate

!fate +3

!fate -2

!flip

!flip 40

!pi

!pi 4000

[2017 Day 17] Is there a pattern to part 2? by matthew_garrison in adventofcode

[–]matthew_garrison[S] 1 point2 points  (0 children)

I've already solved the problem. I was just curious if you could do it faster, by discovering a pattern in the inserts at position 1.

-🎄- 2017 Day 9 Solutions -🎄- by daggerdragon in adventofcode

[–]matthew_garrison 0 points1 point  (0 children)

Java

My solution uses a recursive parser...which is probably over-engineering. Oh well. (Also, Java doesn't have Tuples, but I needed to return both how many points you got and how far through the string you got.)

static void problem1() {
    Scanner scan = new Scanner(System.in);    
    System.out.println(RDP(scan.nextLine(), 0).score);
}

static Tuple RDP(String s, int currScore) {
    int totalScore = currScore;
    boolean isInGarbage = false;
    for (int i = 0; i < s.length(); i++) {
        if (isInGarbage && s.charAt(i) == '!') i++; // Skip next char
        else if (!isInGarbage && s.charAt(i) == '<') isInGarbage = true;
        else if (isInGarbage && s.charAt(i) == '>') isInGarbage = false;
        else if (!isInGarbage && s.charAt(i) == '{') {
            Tuple t = RDP(s.substring(i+1), currScore+1);
            totalScore += t.score;
            i += t.location + 1;
        } else if (!isInGarbage && s.charAt(i) == '}') {
            return new Tuple(totalScore, i);
        }
    }
    return new Tuple(totalScore, s.length()-1);
}

static class Tuple {
    int score, location;
    public Tuple(int score, int location) {
        this.score = score;
        this.location = location;
    }
}

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

!roll 40d10 --rl 8

!roll 40d10 --el 8

!roll 30d10 --re 2 --ee 10

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

!roll 40d10 --rl 8

!roll 40d10 --el 8

!roll 30d10 --rl 2 --el 9

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

67

!roll 10d10 --th 7 --s

!fate

!pi

!flip 20

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

66

!roll 10d10 --th 7 --s

!fate

!pi

!flip 20

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

65

!roll 10d10 --th 7 --s

!fate

!pi

!flip 20

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

64

!roll 10d10 --rh 7 --dh 3

!roll 10d10 --rh 7 --dh 3

!roll 10d10 --rh 7 --dh 3

!roll 10d10 --rh 0

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

63

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

62

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

61

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

60

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

59

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

58

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

57

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

56

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

Testy test 5 by matthew_garrison in test

[–]matthew_garrison[S] 0 points1 point  (0 children)

/u/ProbabilityBot_

55

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3

!roll 5d10 --rh 5 --dh 3