Advertisement
Guest User

Disgust.py

a guest
Jan 20th, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 KB | None | 0 0
  1. data = []
  2.  
  3. with open ("HelloWorld.dis") as file:
  4.     for line in file:
  5.         temp = []
  6.         for cell in line.split("\t"):
  7.             temp.append(int(cell))
  8.         data.append(temp);
  9.  
  10. inst = x = y = 0
  11. try:
  12.     while (x < len(data[0]) and y < len(data) and x >= 0 and y >= 0):
  13.         inst = data[y][x]
  14.  
  15.         if (inst%3 == 0):
  16.             #ADD
  17.             #If the number%3 is 0, add the value below it to it.
  18.             data[y][x] += data[y+1][x]
  19.  
  20.         if (inst%3 == 1):
  21.             #SUBTRACT
  22.             #If the number%3 is 1, subtract the value below it from it
  23.             data[y][x] -= data[y+1][x]
  24.  
  25.         if (inst%7 == 0):
  26.             #OUTPUT
  27.             #If the number%7 is 0, output the ascii character with the value of the cell
  28.             print(chr(data[y][x]))
  29.  
  30.         if (inst%7 == 1):
  31.             #INPUT
  32.             #If the number%7 is 1, store the value of the ascii character inputted in the cell
  33.             data[y][x] = ord(input())
  34.  
  35.         if (inst%2 == 0):
  36.             #SET X
  37.             #If the number is even, inc the y ptr and set the x ptr to the value of the cell
  38.             y += 1
  39.             x = data[y][x]
  40.  
  41.         if (inst%2 == 1):
  42.             #SET Y
  43.             #If the number is odd, inc the x ptr and set the y ptr to the value of the cell
  44.             x += 1
  45.             y = data[y][x]
  46.  
  47.         x += 1
  48. except Exception as e:
  49.     print ("Exception: " + str(e))
  50.     print ("Instruction = " + str(inst) + " (now = " + str(data[y][x]) + ") x = " + str(x) + " y = " + str(y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement