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
| #!/usr/bin/env python | |
| def generate_test_cases(N): | |
| M = 2**N | |
| out = [] | |
| for i in range( M ): | |
| case = [ (i >> j & 0x01) == 1 for j in range( N ) ] | |
| out.append( tuple( case ) ) | |
| return out | |
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
| int fast_compare( const char *ptr0, const char *ptr1, int len ){ | |
| int fast = len/sizeof(size_t) + 1; | |
| int offset = (fast-1)*sizeof(size_t); | |
| int current_block = 0; | |
| if( len <= sizeof(size_t)){ fast = 0; } | |
| size_t *lptr0 = (size_t*)ptr0; | |
| size_t *lptr1 = (size_t*)ptr1; |
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
| #!/usr/bin/env python | |
| # input as dependency graph | |
| # { | |
| # "node1": ["dep1", "dep2"...], | |
| # "node2": [...], | |
| # ... | |
| # } | |
| def solve( graph ): |
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 generic_create_form(name, modelclass): | |
| model_fields = [field.name for field in modelclass._meta.fields] | |
| class Meta: | |
| pass | |
| setattr(Meta,"model", modelclass) | |
| setattr(Meta,"fields", model_fields) | |
| attrs = {'__module__': '', 'Meta': Meta} |
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
| #!/usr/bin/env python | |
| import shlex, pprint | |
| text = """ | |
| (define mauri (lambda (x y) | |
| (+ x y) | |
| ) | |
| ) | |
| (display (mauri 1 2) ) | |
| """ |
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
| #!/usr/bin/env python | |
| import random, itertools | |
| def generate( symbols ): | |
| out = "" | |
| for s in symbols: | |
| out += s | |
| done = False |
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
| #!/usr/bin/env python3.4 | |
| import sys | |
| import shlex | |
| class ParserError(Exception): | |
| pass |
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
| #!/usr/bin/env python | |
| import math | |
| _next_id = -1 | |
| def generate_id(): | |
| global _next_id | |
| _next_id += 1 | |
| return _next_id |
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
| // options | |
| final int OPTION1 = 0; | |
| final int OPTION2 = 1; | |
| final int OPTION3 = 2; | |
| // ad nauseam ... | |
| // usage: if( getBit( flags, OPTION3 ) ){ .... | |
| boolean getBit( int value, int pos ){ |
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
| #!/usr/bin/env python3 | |
| import math, random | |
| def simuloi_nopanheittoa( d, N ): | |
| out = [] | |
| for i in range( N ): | |
| out.append( random.randint( 1, d ) ) | |
| return out |