Skip to content

Instantly share code, notes, and snippets.

View rolisz's full-sized avatar

Roland Szabo rolisz

View GitHub Profile
@rolisz
rolisz / Game of Life
Created December 8, 2012 21:29
Functional Conway's Game of Life
import copy
def next_state(current_state, nr_neighbors):
if (current_state and (nr_neighbors < 2 or nr_neighbors > 3)) or\
(not current_state and nr_neighbors == 3):
return not current_state
return current_state
def are_neighbors(cell1,cell2):
return abs(cell1[0] - cell2[0]) <= 1 and abs(cell1[1] - cell2[1]) <= 1 \
and cell1 != cell2
@rolisz
rolisz / robot.js
Created December 5, 2012 06:05
rolisz
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
@rolisz
rolisz / problema2.asm
Created February 9, 2012 15:05
Rezolvare problema 2 AC grupa 215
assume cs:code, ds:data
data segment
original dd 12A63478h
dd 12345678h
dd 1A2B3C4dh
dd 0FEDC9876h
lungime db (lungime-original)/4
ranks db 10 DUP(?)
suma dw 0
contor db 0
@rolisz
rolisz / insert.py
Created February 4, 2012 18:53
Rezolvare problema 10 examen FP
def insert(list,x):
low = 0
high = len(list) - 1
i = (low+high)//2
while low < high and not (list[i] <= x and list[i+1] > x):
if list[i] < x:
low = i + 1
i = (low+high)//2
else:
high = i - 1
@rolisz
rolisz / prob9.py
Created February 4, 2012 18:07
Rezolvare problema 9 subiect FP
def pow(x,n):
if n==0: return 1
if n==1: return x
res = x
i = 2
while i<= n :
if 2*i < n:
res = res * res
res = res * x
i = i + 1