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 sys | |
def solve(pegs, pfrom, pto, n): | |
if n == 1: | |
pegs[pfrom] -= 1 | |
pegs[pto] += 1 | |
print('{:d}->{:d}'.format(pfrom + 1, pto + 1)) | |
elif n > 1: | |
solve(pegs, pfrom, third_peg(pfrom, pto), n - 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 sys | |
import random | |
def solve(A, total, current, solution): | |
if total == 0: | |
print(' + '.join([str(i) for i in solution]) + ' = ' + str(sum(solution))) | |
return | |
if current >= len(A): |
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
OP_LEFT_FIRST = 0 | |
OP_LEFT_SECOND = 1 | |
OP_ORDER = {'.': -1, '<': 0, '>': 0, '+': 1, '-': 1, '*': 2, '/': 2, '%': 2, '^': 3, '&': 3, '|': 3} | |
def solve(test): | |
items = [] | |
ops = [] | |
for elem in test['eq']: | |
if is_num(elem): |
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
validISBN x y | |
| x > 9 = validISBN (reduce (fromIntegral x)) (extra (fromIntegral x) y) | |
| otherwise = elevens (fromIntegral x) y | |
reduce x = round(x) `mod` (tens x) | |
lvl x = floor $ logBase 10 x | |
extra x y = y + ((round(x) `div` (tens x)) * ((lvl x) + 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 sys | |
import urllib2 | |
import re | |
import HTMLParser | |
def lookup(word_en, limit = 10): | |
url = 'http://szotar.sztaki.hu/search?fromlang=eng&tolang=hun&searchWord=' + word_en + '&langcode=hu&u=0&langprefix=&searchMode=WORD_PREFIX&viewMode=full&ignoreAccents=0' | |
result = urllib2.urlopen(url) | |
h = HTMLParser.HTMLParser() |
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
// The script requires your GitHub token. | |
// It fetches the teams for a given organisation. | |
// Then goes through one team's repos. | |
// Config file format: | |
// { | |
// "personalToken": "TOKEN_FROM_GITHUB", | |
// "orgName": "SELECTED_ORG_NAME", | |
// "teamName": "SELECTED_TEAM_NAME" | |
// } |
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
<?php | |
/** | |
* @file | |
* | |
* SANDBOX. | |
*/ | |
/** | |
* Implements hook_boot(). | |
*/ |
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
package main | |
import ( | |
"log" | |
) | |
func solve(digits []uint, cmp func(uint, uint) bool) []uint { | |
currentPos := 0 | |
replacePos := 0 | |
foundPos := -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 java.lang.reflect.Method; | |
public class Main { | |
public static void main(String[] args) { | |
AnimalParam ap = new AnimalParam("A"); | |
AnimalFactory<Animal, AnimalParam> af = new AnimalFactory<Animal, AnimalParam>(); | |
Animal a = af.create(Animal.class, AnimalParam.class, ap); | |
System.out.println(a); | |
BirdParam bp = new BirdParam("B", "C"); |
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 math | |
crop = [] | |
width = 0 | |
height = 0 | |
diameter = 0 | |
total_cache = [] | |
offset_cache = [] |