Skip to content

Instantly share code, notes, and snippets.

View rolisz's full-sized avatar

Roland Szabo rolisz

View GitHub Profile
@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
@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 / 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 / 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 / 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 / scrape_notebook.ipynb
Created February 14, 2013 15:16
IPython notebook cu scraping la notele de la BD, PLF, PS ca sa obtinem toate notele bine organizate la un loc.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rolisz
rolisz / img.py
Created March 17, 2013 14:05
For Catalin with multiprocessing
from multiprocessing import Pool
__author__ = 'Roland'
from PIL import Image
#size of image
imgx = 600
imgy = 400
#make image buffer
image = Image.new("RGB", (imgx, imgy))
@rolisz
rolisz / scris.lsp
Created January 4, 2014 10:21
Pregatire pentru examenul scris la PLF, LISP
(defun inserare(el l)
(cond
((null l) nil)
(t (mapcar (lambda (x) (cons el x)) l))
)
)
(defun permutare(l)
(cond
((null l) '(()))
@rolisz
rolisz / avl.py
Created June 19, 2014 17:53
AVL tree in python
__author__ = 'Roland'
import copy
class avl:
def __init__(self,value = None,left = None,right = None,parent = None):
self.value = value
self.left = left
self.right = right
self.parent = parent
@rolisz
rolisz / NeuralNetwork.py
Created July 17, 2014 12:04
Neural network
import numpy as np
from numpy.random import random as rand
class NeuralNetwork:
activations = {
'tanh': lambda x: np.tanh(x),
'relu': lambda x: np.clip(x, 0, np.max(x))
}
derivatives = {