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
$pdf_previewer = "start evince"; | |
$pdf_update_method = 0; | |
$pdf_mode = 1; | |
add_cus_dep('glo', 'gls', 0, 'makeglo2gls'); | |
sub makeglo2gls { | |
system("makeindex -s '$_[0]'.ist -t '$_[0]'.glg -o '$_[0]'.gls '$_[0]'.glo"); | |
} |
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 main(): | |
from sys import stdin | |
rl=stdin.readline | |
rl() | |
rl() | |
root = rl().rstrip() | |
ratatosk = rl().rstrip() | |
parent = {} | |
count = 0 | |
for node in stdin: |
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 sys import stdin | |
import re | |
__author__="Jonas Svarvaa" | |
__date__ ="$06.sep.2010 12:39:53$" | |
def parse_input(): | |
words = {} | |
pos = 0 | |
for s in stdin.readline().split(): | |
try: |
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
# coding=utf-8 | |
# Kobra lærer å stave av Sigurd Fosseng | |
def main(): | |
from sys import stdin | |
s = raw_input().split() | |
queries = stdin.read() | |
word_tree = {'':{}} | |
word_places = {} | |
sted = 0 | |
if '?' in queries: |
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
# coding=utf-8 | |
''' | |
File: hanoi.py | |
Author: Sigurd Fosseng, Håkon Røkenes | |
Description: Solves towers of hanoi | |
http://en.wikipedia.org/wiki/Tower_of_Hanoi#Simpler_statement_of_iterative_solution | |
''' | |
def legal_move(m, n): |
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
#!/usr/bin/python | |
#-*- coding: utf-8 | |
""" | |
This script formats emails for easier replying | |
Strips out greetings and signatures | |
usage: | |
$ cat mail.txt | python script.py | |
""" | |
greetings = ["Hello", "Hei" "Hei!"] |
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
Jeg er nabo med: nummere er noder | |
1 2 3 | |
1 x x | |
2 x | |
3 x |
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
#evaluate hand | |
good_hand = False | |
if phase == 0: | |
if self.card_power[0] == 2: | |
good_hand = True | |
elif self.card_power[0] == 1 and self.card_power[1] > 7: | |
good_hand = True | |
elif self.card_power[0] >= 2: | |
good_hand = True |
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 normalize(vector): | |
""" returns a new normalized array """ | |
vector = np.array(vector).reshape(2).reshape(2) # back to 1D array | |
s = sum(vector) # sum of the vector | |
return np.array([n / s for n in vector.flat]) # normalize |
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 randperm(self,(seq)): | |
"""Randomly permutes the sequences in the seq tuple with | |
every sequence permuted in the same order""" | |
perm = permutation(len(seq[0])) | |
return [list(numpy.array(s)[perm]) for s in seq] |
OlderNewer