This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder