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 random | |
# gyors kombinatorikai modell a 10 élre | |
all_edges = [(i, j) for i in range(5) for j in range(5) if i!=j and i<j] | |
def negyszog_e(elek): | |
# akkor négyszög ha a négy él négy csúcsot ad meg és minden csúcs fokszáma 2 | |
pontok = {} | |
for i,j in elek: | |
pontok[i] = pontok.get(i, 0) + 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 swap(char): | |
return chr(swap_ascii(ord(char))) | |
def swap_ascii(code): | |
if code>=65 and code<=90: | |
return 155-code | |
# 90 - (code-65) = 90+65-code = 115-code | |
elif code>=97 and code<=122: | |
return 219-code | |
# similarly from 112-(code-97) |
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 timeit | |
def fib(n): | |
if n==1 or n==2: | |
return 1 | |
return fib(n-1) + fib(n-2) | |
print(timeit.timeit("fib(10)", "from __main__ import fib", number=1, )) | |
print(timeit.timeit("fib(20)", "from __main__ import fib", number=1, )) | |
print(timeit.timeit("fib(30)", "from __main__ import fib", number=1, )) | |
print(timeit.timeit("fib(40)", "from __main__ import fib", number=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
import random | |
import timeit | |
def setup_map(data, num): | |
for _ in range(num): | |
data[random.random()] = random.random() | |
map = {} | |
setup_map(map, 100000) |
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
from collections import namedtuple, deque | |
from sys import stdin, stdout | |
class SVM: | |
def __init__(self, progmem = "H", stack = [], status = [0, False]): | |
self.progmem = progmem | |
self.stack = deque(stack) | |
self.PC, self.HALT = status | |
def step(self): |
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 num_to_str(n): | |
return "{:012b}".format(n) | |
def has_four(s): | |
return sum(int(ch) for ch in s)==4 | |
def no_next_to(s): | |
return s.find("11")==-1 | |
all_possible = list(filter(no_next_to, filter(has_four, map(num_to_str, range(2**12))))) |
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 extractJSON(string): | |
extracted = "" | |
seen = 0 | |
in_string = False | |
escape = False | |
for char in string: | |
if char=="{" and not in_string: | |
seen += 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
from collections import deque | |
""" | |
Input your (not) fully specified state table here | |
""" | |
T = [ | |
["a", ["h", "1"], ["f", "-"]], | |
["b", ["c", "1"], ["h", "1"]], | |
["c", ["b", "0"], ["a", "0"]], | |
["d", ["d", "1"], ["-", "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
#include <stdint.h> | |
#include <stdio.h> | |
uint64_t csoeoe(uint64_t thatFirstParam, uint64_t paramNumberOne, uint64_t dQw4w9WgXcQ) { | |
return (int64_t)(((__int128_t)thatFirstParam*paramNumberOne)%dQw4w9WgXcQ); | |
} | |
uint64_t fueuetoeoecsoeoe(uint64_t ZWxzb1BhcmFtZXRlcg, uint64_t bWFzb2Rpa1BhcmFtZXRlcg, uint64_t dXRvbHNvUGFyYW1ldGVy) | |
{ | |
uint64_t dmFsYW1pUmFuZG9tVmFsdG96bw = 1; |