Skip to content

Instantly share code, notes, and snippets.

@nandakoryaaa
nandakoryaaa / merge_sort_bingo.py
Last active February 16, 2023 22:02
Merge sort implementing true external sequential file/stream emulation
def read_chunk(dst, src, chunk_size, pos, len_src):
while chunk_size > 0 and pos < len_src:
dst.append(src[pos])
pos += 1
chunk_size -= 1
return pos
def get_bingo_size(pos, chunk_size, len_src):
if pos + chunk_size > len_src:
return len_src - pos
class State:
state_handlers = {
's_open': ('h_open', 'h_num'),
's_close': ('h_close', 'h_op'),
's_num': ('h_num'),
's_op': ('h_op')
}
state_map = {
'h_open': 's_open',
from random import randint
import pygame
from pygame.locals import *
import time
W = 10
PLAYER = 20
ROBOT = 30
DEAD_ROBOT = 35
HAZARD = 40