コード例 #1
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(solution(1212), 6)
     self.assertEqual(solution(1221), 0)
     self.assertEqual(solution(123425), 4)
     self.assertEqual(solution(123123), 12)
     self.assertEqual(solution(12131415), 4)
コード例 #2
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(solution(256, ""), "a2582a3a0e66e6e86e3812dcb672a272")
     self.assertEqual(solution(256, "AoC 2017"),
                      "33efeb34ea91902bb2f59c9920caa6cd")
     self.assertEqual(solution(256, "1,2,3"),
                      "3efbe78a8d82f29979031a4aa0b16a9d")
     self.assertEqual(solution(256, "1,2,4"),
                      "63960835bcdc130f0b66d7ff4f6a5a8e")
コード例 #3
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(
            solution("""b inc 5 if a > 1
a inc 1 if b < 5
c dec -10 if a >= 1
c inc -20 if c == 10"""), 1)
コード例 #4
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(
            solution("""set b 81
set c b
jnz a 2
jnz 1 5
mul b 100
sub b -100000
set c b
sub c -17000
set f 1
set d 2
set e 2
set g d
mul g e
sub g b
jnz g 2
set f 0
sub e -1
set g e
sub g b
jnz g -8
sub d -1
set g d
sub g b
jnz g -13
jnz f 2
sub h -1
set g b
sub g c
jnz g 2
jnz 1 3
sub b -17
jnz 1 -23"""), 6241)
コード例 #5
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(
            solution("""Begin in state A.
Perform a diagnostic checksum after 6 steps.

In state A:
  If the current value is 0:
    - Write the value 1.
    - Move one slot to the right.
    - Continue with state B.
  If the current value is 1:
    - Write the value 0.
    - Move one slot to the left.
    - Continue with state B.

In state B:
  If the current value is 0:
    - Write the value 1.
    - Move one slot to the left.
    - Continue with state A.
  If the current value is 1:
    - Write the value 1.
    - Move one slot to the right.
    - Continue with state A."""), 3)
コード例 #6
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(row("5	1	9	5"), 8)
     self.assertEqual(row("7	5	3"), 4)
     self.assertEqual(row("2	4	6	8"), 6)
     self.assertEqual(solution("""5	1	9	5
     7	5	3
     2	4	6	8"""), 18)
コード例 #7
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(solution("{}"), 1)
     self.assertEqual(solution("{{{}}}"), 6)
     self.assertEqual(solution("{{},{}}"), 5)
     self.assertEqual(solution("{{{},{},{{}}}}"), 16)
     self.assertEqual(solution("{<a>,<a>,<a>,<a>}"), 1)
     self.assertEqual(solution("{{<ab>},{<ab>},{<ab>},{<ab>}}"), 9)
     self.assertEqual(solution("{{<!!>},{<!!>},{<!!>},{<!!>}}"), 9)
     self.assertEqual(solution("{{<a!>},{<a!>},{<a!>},{<ab>}}"), 3)
コード例 #8
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(solution("""0 <-> 2
1 <-> 1
2 <-> 0, 3, 4
3 <-> 2, 4
4 <-> 2, 3, 6
5 <-> 6
6 <-> 4, 5"""), 6)
コード例 #9
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(
            solution("""     |          
     |  +--+    
     A  |  C    
 F---|----E|--+ 
     |  |  |  D 
     +B-+  +--+ """), "ABCDEF")
コード例 #10
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(row("5	9	2	8"), 4)
     self.assertEqual(row("9	4	7	3"), 3)
     self.assertEqual(row("3	8	6	5"), 2)
     self.assertEqual(
         solution("""5	9	2	8
             9	4	7	3
             3	8	6	5"""), 9)
コード例 #11
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(solution("""0/2
2/2
2/3
3/4
3/5
0/1
10/1
9/10"""), 31)
コード例 #12
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(
            solution("""snd 1
snd 2
snd p
rcv a
rcv b
rcv c
rcv d"""), 3)
コード例 #13
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(solution("<>"), 0)
     self.assertEqual(solution("<random characters>"), 17)
     self.assertEqual(solution("<<<<>"), 3)
     self.assertEqual(solution("<{!>}>"), 2)
     self.assertEqual(solution("<!!>"), 0)
     self.assertEqual(solution("<!!!>>"), 0)
     self.assertEqual(solution("""<{o"i!a,<{i<a>"""), 10)
コード例 #14
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(
            solution("""set a 1
add a 2
mul a a
mod a 5
snd a
set a 0
rcv a
jgz a -1
set a 1
jgz a -2"""), 4)
コード例 #15
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(
            solution("""pbga (66)
xhth (57)
ebii (61)
havc (66)
ktlj (57)
fwft (72) -> ktlj, cntj, xhth
qoyq (66)
padx (45) -> pbga, havc, qoyq
tknk (41) -> ugml, padx, fwft
jptl (61)
ugml (68) -> gyxo, ebii, jptl
gyxo (61)
cntj (57)"""), ["tknk"])
コード例 #16
0
 def test_none(self):
     """ Nothing repeats """
     self.assertEqual(solution(1234), 0)
コード例 #17
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(solution(3), 1222153)
コード例 #18
0
 def test_custom(self):
     """ My test cases """
     self.assertEqual(solution(57), 59)
コード例 #19
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(solution(2), 4)
     self.assertEqual(solution(3), 4)
     self.assertEqual(solution(4), 5)
     self.assertEqual(solution(5), 10)
コード例 #20
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(solution("""../.# => ##./#../...
.#./..#/### => #..#/..../..../#..#""", 2), 12)
コード例 #21
0
 def test_allsame(self):
     """ All element is the same """
     self.assertEqual(solution(1111), 4)
コード例 #22
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(solution(12), 3)
     self.assertEqual(solution(23), 2)
     self.assertEqual(solution(1024), 31)
     self.assertEqual(solution(1), 0)
コード例 #23
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(solution("""..#
#..
..."""), 2511944)
コード例 #24
0
 def test_rotate(self):
     """ The only matching elem is in the end """
     self.assertEqual(solution(91212129), 9)
コード例 #25
0
    def test_match(self):
        """ The basic test cases """
        self.assertEqual(
            solution("""Generator A starts with 699
Generator B starts with 124"""), 588)
コード例 #26
0
 def test_basic(self):
     """ Summary is good """
     self.assertEqual(solution(1122), 3)
コード例 #27
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(solution("""set b 81"""), 909)
     self.assertEqual(solution("""set b 79"""), 907)
コード例 #28
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(solution("0\t2\t7\t0"), 4)
コード例 #29
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(solution("ne,ne,ne"), 3)
     self.assertEqual(solution("ne,ne,sw,sw"), 2)
     self.assertEqual(solution("ne,ne,s,s"), 2)
     self.assertEqual(solution("se,sw,se,sw,sw"), 3)
コード例 #30
0
 def test_match(self):
     """ The basic test cases """
     self.assertEqual(solution("0\n3\n0\n1\n-3"), 5)