Esempio n. 1
0
 def test_translate(self):
     scotty = Scotty()
     res = scotty.translate('1,0,0,3,99')
     self.assertEqual(res, [1, 0, 0, 3, 99])
Esempio n. 2
0
 def test_execute_four(self):
     scotty = Scotty()
     trans = scotty.translate('2,4,4,5,99,0')
     res = scotty.execute(trans)
     self.assertEqual(res, [2, 4, 4, 5, 99, 9801])
Esempio n. 3
0
 def test_execute_five(self):
     scotty = Scotty()
     trans = scotty.translate('1,1,1,4,99,5,6,0,99')
     res = scotty.execute(trans)
     self.assertEqual(res, [30, 1, 1, 4, 2, 5, 6, 0, 99])
Esempio n. 4
0
 def test_execute_two(self):
     scotty = Scotty()
     trans = scotty.translate('1,9,10,3,2,3,11,0,99,30,40,50')
     res = scotty.execute(trans)
     self.assertEqual(res, [3500, 9, 10, 70, 2, 3, 11, 0, 99, 30, 40, 50])
Esempio n. 5
0
 def test_execute_three(self):
     scotty = Scotty()
     trans = scotty.translate('2,3,0,3,99')
     res = scotty.execute(trans)
     self.assertEqual(res, [2, 3, 0, 6, 99])
Esempio n. 6
0
import random
import os
from enterprise import MontgomeryScott as Scotty

cwd = os.getcwd()
ifile = cwd + "/input.txt"

with open(ifile, "r") as commands:
    #Part one
    scotty = Scotty(input=1)
    trans = scotty.translate(commands.read())
    res = scotty.execute(trans.copy())
    print("Scotty says the solution for part one is: {0}".format(res[-1]))

    #Part two
    scotty = Scotty(input=5)
    res = scotty.execute(trans.copy())
    print("Scotty says the solution for part two is: {0}".format(res[-1]))
Esempio n. 7
0
 def test_execute_one(self):
     scotty = Scotty()
     trans = scotty.translate('1,0,0,3,99')
     res = scotty.execute(trans)
     self.assertEqual(res, [1, 0, 0, 2, 99])
Esempio n. 8
0
 def test_translate(self):
     scotty = Scotty(input=1)
     res = scotty.translate('3,0,4,0,99')
     self.assertEqual(res, [3, 0, 4, 0, 99])
Esempio n. 9
0
 def test_execute_im_more_than_eight(self):
     scotty = Scotty(input=9)
     trans = scotty.translate('3,3,1107,-1,8,3,4,3,99')
     res = scotty.execute(trans)
     self.assertEqual(res, [0])
Esempio n. 10
0
 def test_execute_im_not_equal_eight(self):
     scotty = Scotty(input=1)
     trans = scotty.translate('3,3,1108,-1,8,3,4,3,99')
     res = scotty.execute(trans)
     self.assertEqual(res, [0])
Esempio n. 11
0
 def test_execute_pos_more_than_eight(self):
     scotty = Scotty(input=9)
     trans = scotty.translate('3,9,7,9,10,9,4,9,99,-1,8')
     res = scotty.execute(trans)
     self.assertEqual(res, [0])
Esempio n. 12
0
 def test_execute_pos_not_equal_eight(self):
     scotty = Scotty(input=1)
     trans = scotty.translate('3,9,8,9,10,9,4,9,99,-1,8')
     res = scotty.execute(trans)
     self.assertEqual(res, [0])