This file contains 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 django import forms | |
from django.core import validators | |
from django.core.exceptions import ValidationError | |
class MinLengthValidator(validators.MinLengthValidator): | |
message = 'Ensure this value has at least %(limit_value)d elements (it has %(show_value)d).' | |
class MaxLengthValidator(validators.MaxLengthValidator): | |
message = 'Ensure this value has at most %(limit_value)d elements (it has %(show_value)d).' |
This file contains 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 time | |
def generator(input, factor, criteria): | |
value = input | |
ignored = 0 | |
while True: | |
value = (value * factor) % 2147483647 | |
if (value % criteria) == 0: | |
yield value, ignored | |
else: |
This file contains 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 _replace(data, position, chunk): | |
#print position, chunk | |
for idx, v in enumerate(chunk): | |
data[position+idx] = v | |
def hash_list(lengths, data, position=0, skip_size=0): | |
#print position, skip_size, data | |
base_len = len(data) | |
for length in lengths: |
This file contains 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
INPUT = """0: 3 | |
1: 2 | |
2: 4 | |
4: 6 | |
6: 5 | |
8: 8 | |
10: 6 | |
12: 4 | |
14: 8 | |
16: 6 |
This file contains 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
INPUT = """0 <-> 454, 528, 621, 1023, 1199 | |
1 <-> 1335, 1563, 1627, 1679 | |
2 <-> 353, 689 | |
3 <-> 3, 1171 | |
4 <-> 1247 | |
5 <-> 758, 928, 1260 | |
6 <-> 1010 | |
7 <-> 570 | |
8 <-> 710, 1610 | |
9 <-> 9 |
This file contains 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
INPUT = """ne,n,ne,s,nw,s,s,sw,sw,sw,sw,sw,nw,nw,sw,nw,nw,n,nw,nw,nw,nw,nw,s,n,nw,s,n,n,nw,n,n,se,n,n,n,s,n,n,n,n,sw,se,n,n,ne,s,ne,ne,nw,ne,n,ne,ne,ne,ne,ne,s,ne,ne,s,se,ne,ne,ne,ne,ne,nw,ne,se,ne,ne,n,ne,ne,se,ne,ne,se,se,se,se,se,n,se,ne,se,se,ne,ne,se,sw,sw,se,se,s,sw,se,se,se,s,n,se,se,s,se,s,se,se,se,se,se,se,n,s,s,nw,se,s,s,nw,s,se,se,s,s,s,sw,s,s,se,n,ne,s,s,s,s,s,s,nw,s,n,s,n,se,s,s,sw,s,ne,s,s,s,s,s,nw,ne,s,s,sw,s,s,s,s,se,n,nw,s,s,s,s,s,sw,s,n,sw,s,s,sw,sw,s,sw,sw,ne,sw,sw,s,ne,s,sw,sw,sw,sw,s,sw,se,sw,sw,s,sw,se,s,sw,sw,sw,se,sw,sw,sw,sw,s,sw,s,sw,s,sw,sw,ne,sw,sw,ne,sw,sw,s,sw,sw,sw,ne,sw,sw,sw,sw,se,se,sw,nw,sw,sw,nw,sw,nw,nw,sw,sw,sw,sw,nw,sw,nw,sw,sw,nw,sw,n,sw,nw,sw,s,s,se,nw,s,nw,sw,nw,nw,sw,nw,s,nw,se,s,sw,se,nw,nw,n,sw,sw,nw,sw,nw,nw,nw,ne,sw,ne,se,sw,sw,ne,nw,sw,nw,nw,nw,ne,nw,nw,sw,nw,sw,nw,sw,nw,nw,nw,nw,nw,ne,nw,nw,nw,nw,nw,nw,nw,ne,nw,nw,nw,nw,nw,nw,nw,ne,ne,nw,s,sw,nw,nw,nw,se,nw,se,se,nw,nw,nw,n,nw,nw,ne,nw,nw,nw,ne,nw,n,sw,nw,ne,nw,sw,nw,n,nw,s,nw,n,nw,nw,nw,nw,nw,n,n,sw,nw,nw,n,nw |
This file contains 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
INPUT = """165,1,255,31,87,52,24,113,0,91,148,254,158,2,73,153""" | |
import asciitree | |
from collections import OrderedDict, defaultdict | |
def _replace(data, position, chunk): | |
#print position, chunk | |
for idx, v in enumerate(chunk): | |
data[position+idx] = v | |
This file contains 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
TESTSCORES = [ | |
("{}", 1), | |
("{{{}}}", 6), | |
("{{},{}}", 5), | |
("{{{},{},{{}}}}", 16), | |
("{<a>,<a>,<a>,<a>}", 1), | |
("{{<ab>},{<ab>},{<ab>},{<ab>}}", 9), | |
("{{<!!>},{<!!>},{<!!>},{<!!>}}", 9), | |
("{{<a!>},{<a!>},{<a!>},{<ab>}}", 3), | |
] |
This file contains 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
TEST = """pb inc 5 if a > 1 | |
a inc 1 if b < 5 | |
c dec -10 if a >= 1 | |
c inc -20 if c == 10""" | |
INPUT = """uz inc 134 if hx > -10 | |
qin dec -300 if h <= 1 | |
ubi inc 720 if qin <= 306 | |
si inc -108 if he <= 1 | |
hx inc 278 if hx <= -10 |
This file contains 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
TEST = """pbga (66) | |
xhth (57) | |
ebii (61) | |
havc (66) | |
ktlj (57) | |
fwft (72) -> ktlj, cntj, xhth | |
qoyq (66) | |
padx (45) -> pbga, havc, qoyq | |
tknk (41) -> ugml, padx, fwft | |
jptl (61) |
NewerOlder