def print_life_lost(): os.system('clear') print("YOU LOST A LIFE") for row in range(6): for col in range(7): if row == 0 and col % 3 != 0 or row == 1 and col % 3 == 0 or row - col == 2 or row + col == 8: print('*', end="") else: print(" ", end=" ") print() print("Press SPACE to continue") while (1): char = input.get() if char == " ": return
def print_game_over(): os.system('clear') print("GAME OVER") for row in range(6): for col in range(7): if row == 0 and col % 3 != 0 or row == 1 and col % 3 == 0 or row - col == 2 or row + col == 8: print('*', end="") else: print(" ", end=" ") print() print("Press SPACE to END GAME") while (1): char = input.get() if char == " ": return
def start_game(): paddle = paddleBoi() arena_instance = Arena_Board(paddle) os.system('clear') while True: gameEnd = game_loop(arena_instance, paddle) char = input.get() if char == 'q': gameEnd += end_game() else: paddle_handler(arena_instance, paddle, char) if gameEnd == 1: break
def startGame(): # create instances of mando'a and initialize the score to zero and what not # Creating our character jango = Mandalorian() os.system('clear') boardInstance = GameBoard(jango) #for i in range(10): while (1): gameEnd = gameLoop(boardInstance, jango) char = input.get() if char == 'q': gameEnd += endGame() else: mandoHandler(boardInstance, jango, char) if gameEnd == 1: break
import input groups = input.get(6).split('\n\n') # Get the uniques. Easiest way is to use a set print(sum([len(set(list(x.replace('\n', '')))) for x in groups])) def compare(lists): return lists[0].intersection(*lists) print( sum([len(compare([set(list(y)) for y in x.splitlines()])) for x in groups]))
if i + self.currentTab * len(TILETYPES) == self.selectedTileNum: self.surf.blit(self.selectedImg, (i * CELLSIZE, 0)) tabSurf, tabRect = genText( str(self.currentTab), (self.rect.left - 20, self.rect.top + 20), (50, 50, 50), BIGFONT ) screen.blit(tabSurf, tabRect) screen.blit(self.surf, self.rect) screen.blit(self.overlay, self.rect) mode = "input title" modalInput = ModalInput((200, WINDOWHEIGHT / 2), "text", "Level name") while True: input.get() screen.fill((255, 255, 255)) if mode == "input title": output = modalInput.update() if output != None: levelName = output if os.path.exists("assets/levels/%s.pickle" % (levelName)): mode = "edit level" with open("assets/levels/%s.pickle" % (levelName), "rb") as handle: loadedLevelData = pickle.load(handle) levelData = LevelData(levelName, dataDict=loadedLevelData) tilePicker = TilePicker() else:
from math import ceil from input import get print('starting...') text = get(3) lines = text.splitlines() print('working...') def slider(right: int, down: int, slopelines): slope = [] slope[:] = slopelines coords = [0, 0] trees = 0 height = len(slope) width = len(slope[0]) folds = ceil((height * right) / width) for l in range(len(slope)): slope[l] = slope[l] * folds while coords[1] < (height - 1): coords[0] += right coords[1] += down row = coords[1] col = coords[0] if slope[row][col] == '#': trees += 1
from input import get print('starting...') text = get(4) lines = text.splitlines() print('parsing...') # expected fields: # byr (Birth Year) # iyr (Issue Year) # eyr (Expiration Year) # hgt (Height) # hcl (Hair Color) # ecl (Eye Color) # pid (Passport ID) # cid (Country ID) <-- optional # input ex: # ecl:gry pid:860033327 eyr:2020 hcl:#fffffd # byr:1937 iyr:2017 cid:147 hgt:183cm # # iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884 # hcl:#cfa07d byr:1929 # # hcl:#ae17e1 iyr:2013 # eyr:2024 # ecl:brn pid:760753108 byr:1931 # hgt:179cm
from MainFrame import * from CurvatureGraph import * import input import thread try: # Inicio do programa e das threads para rodar o grafico e a curva input.get() thread.start_new_thread(graph, ()) thread.start_new_thread(main, ()) except KeyboardInterrupt: thread.exit() while 1: pass
import input import re data = input.get(4) passports = [dict([y.split(':') for y in x.replace('\n', ' ').split(' ')]) for x in data.split('\n\n')] req = ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid'] # Check for all required fields print(len([pp for pp in passports if len([x for x in req if x not in pp]) == 0])) def between(min, max): return lambda value: value.isdigit() and int(value) >= min and int(value) <= max validations = { 'byr': between(1920, 2002), 'iyr': between(2010, 2020), 'eyr': between(2020, 2030), 'hgt': lambda value: (between(150, 193) if value[-2:] == 'cm' else between(59, 76))(value[:-2]), 'hcl': lambda value: re.match(r"^#[a-f0-9]{6}$", value), 'ecl': lambda value: value in ['amb','blu','brn','gry','grn','hzl','oth'], 'pid': lambda value: re.match(r"^[0-9]{9}$", value) } def isValid(passport): return len([k for (k, v) in validations.items() if k not in passport or not v(passport[k])]) == 0 print(len([x for x in passports if isValid(x)]))
from input import get print('starting...') text = get(5) lines = text.splitlines() print('parsing...')
from input import get print('starting...') text = get(2) lines = text.splitlines() valid = 0 print('parsing...') for line in lines: values = str(line).split(' ') # ex: ['11-15','d:','ddddddddddzdpdn'] limits = values[0].split('-') min = int(limits[0]) max = int(limits[1]) needed = values[1].strip(':') match = 0 if values[2][min - 1] == needed: match += 1 if values[2][max - 1] == needed: match += 1 if match == 1: valid += 1 print('valid: ' + str(valid)) print('done')