Skip to content

Instantly share code, notes, and snippets.

View laat's full-sized avatar
💤

Sigurd Fosseng laat

💤
View GitHub Profile
$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");
}
def main():
from sys import stdin
rl=stdin.readline
rl()
rl()
root = rl().rstrip()
ratatosk = rl().rstrip()
parent = {}
count = 0
for node in stdin:
@laat
laat / o3.py
Created September 6, 2010 16:15 — forked from anonymous/o3.py
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:
# 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:
@laat
laat / hanoi.py
Created November 17, 2010 16:56
Solves towers of hannoi
# 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):
@laat
laat / strip_mail.py
Created July 18, 2011 20:36
edits mails for easier replying
#!/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!"]
Jeg er nabo med: nummere er noder
1 2 3
1 x x
2 x
3 x
@laat
laat / player.py
Created September 28, 2011 15:45
#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
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
@laat
laat / hax.py
Created October 25, 2011 15:26
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]