def main():
    #positions = [x[i] for x in itertools.permutations(range(0,50), 2) for i in range(0, 2)]
    def getrow(y, offset):
        for x in range(offset + 1, 50):
            if COMPUTER.start(program[:], [x, y])[0] == 0:
                return complex(offset, x - offset)

    rows = []
    offset = 0
    for y in range(0, 50):
        for x in range(offset, 50):
            if COMPUTER.start(program[:], [x, y])[0] == 1:
                offset = x
                rows.append(getrow(y, offset))
                break
        else:
            rows.append(complex(0, 0))

    text = ''
    count = 0
    for r in rows:
        text += int(r.real) * ' ' + int(
            r.imag) * u'\u2588' + int(50 - r.real - r.imag) * ' ' + '\n'
        count += r.imag
    print text
    print "affected points: " + str(int(count))
    return count
def main():
    instr = instructions()
    instr.add('NOT A J')
    instr.add('NOT B T')
    instr.add('OR T J')
    instr.add('NOT C T')
    instr.add('OR T J')
    instr.add('AND D J')

    output = COMPUTER.start(program, instr.getinstruction())
    writetoscreen(output)
Example #3
0
def main():
    instr = instructions()
    instr.add('NOT A J')
    instr.add('NOT B T')
    instr.add('OR T J')
    instr.add('NOT C T')
    instr.add('OR T J')  #A/B/C = AIR (should jump)

    instr.add('NOT A T')
    instr.add('OR H T')
    instr.add('OR E T')
    instr.add('AND D T')  #H/E AND D IS LAND (is save to jump)

    instr.add('AND T J')  #should and can jump

    output = COMPUTER.start(program, instr.getinstruction())
    writetoscreen(output)
def main():
    return str(COMPUTER.start(program, [1])[0])
import Day09_Computer as COMPUTER

program = COMPUTER.getprogram('Day09/Day09_Input.txt')

def main():
    return str(COMPUTER.start(program, [1])[0])

if __name__ == '__main__':
    print main()
import sys, os
sys.path.append(
    (os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +
     '/Day09/'))

import Day09_Computer as COMPUTER

import Queue
from threading import Thread
from os import system
from getkey import getkey, keys

program = COMPUTER.getprogram('Day13/Day13_Input.txt')


class screen():
    def __init__(self):
        self.pixels = [[0]]

    def writetoscreen(self):
        text = ''
        for r in self.pixels:
            text += self.writerow(r) + '\n'
        system('cls')
        print text

    def writerow(self, row):
        line = ''
        for p in row:
            if p == 0:
                line += ' '
Example #7
0
import sys, os

sys.path.append(
    (os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +
     '/Day09/'))

import Day09_Computer as COMPUTER
program = COMPUTER.getprogram('Day21/Day21_Input.txt')


class instructions():
    def __init__(self):
        self.myinstruction = []

    def texttoinstruction(self, text):
        instruction = []
        for c in text:
            instruction.append(ord(c))
        instruction.append(10)  #\n
        return instruction

    def add(self, text):
        self.myinstruction.extend(self.texttoinstruction(text))

    def getinstruction(self):
        instruction = self.myinstruction
        instruction.extend(self.texttoinstruction('RUN'))
        return instruction


def main():
import sys, os, itertools

sys.path.append(
    (os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +
     '/Day09/'))

import Queue
from threading import Thread

import Day09_Computer as COMPUTER
program = COMPUTER.getprogram('Day25/Day25_Input.txt')

layout = {}
routetopressuresensitivefloor = []
banneditems = [
]  #['escape pod', 'giant electromagnet', 'photons', 'infinite loop', 'molten lava']
items = []
lastitem = ''
alive = True


def writetoscreen(output):
    text = ''
    for c in output:
        text += unichr(c)
    print text
    return text


def tounicodelist(string):
    unicodelist = []
import sys, os

sys.path.append((os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+ '/Day09/'))

import Day09_Computer as COMPUTER

import Queue
from threading import Thread

program = COMPUTER.getprogram('Day17/Day17_Input.txt')

class screen():
    def __init__(self, myrobot):
        self.pixels = [[]]
        self.robot = myrobot

    def outputtopixels(self, output):
        self.pixels = []
        width = output.index(10)
        for row in (output[x:x + width] for x in range(0, len(output) - 1, width + 1)):
            self.pixels.append(row)
            if row.count(94) != 0:
                self.robot.pos = [len(self.pixels) - 1, row.index(94)]

    def writetoscreen(self, input, cls = False):
        text = ''
        for c in input:
            text += str(unichr(c))
        if cls:
            os.system('cls')
 def getpos(x, y):
     return COMPUTER.start(program[:], [x, y])[0]
 def getrow(y, offset):
     for x in range(offset + 1, 50):
         if COMPUTER.start(program[:], [x, y])[0] == 0:
             return complex(offset, x - offset)