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 load_graph(): | |
g = {} | |
with open('sample.txt', 'r') as f: | |
for line in filter(lambda l: l != '\n', f): | |
row = line.split('\t') | |
g[int(row[1])] = list(map(int, row[2:])) | |
return g |
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
<!doctype html> | |
<body> | |
<style> | |
td.selected { | |
background: red; | |
} | |
</style> | |
<script> | |
const N = 100; | |
const ROWS = 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
# https://www.facebook.com/photo.php?fbid=10155461108530633&set=p.10155461108530633&type=3&theater&ifg=1 | |
def prettyPrint(lista): | |
# Funktionen tar en lista med koefficienter | |
# till ett polynom i avtagande ordning och | |
# skriver ut polynomet | |
# Polynomets gradtal | |
polynomets_gradtal = len(lista) - 1 | |
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 math import factorial | |
e = 0 | |
for k in range(0, 20): | |
e += 1/factorial(k) | |
print("k=% 3d: e=%.16f" % (k, e,)) | |
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
# https://www.facebook.com/groups/progfml/permalink/344454616128233/ | |
from math import factorial | |
e=0 | |
n=0 | |
step_length=1 | |
e_right=2.71828 | |
margin_of_error=0.001 | |
Klart=False |
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
toSwedish :: Integer -> String | |
toSwedish 1 = "ett" | |
toSwedish 2 = "två" | |
toSwedish 3 = "tre" | |
toSwedish 4 = "fyra" | |
toSwedish 5 = "fem" | |
toSwedish 6 = "sex" | |
toSwedish 7 = "sju" | |
toSwedish 8 = "åtta" | |
toSwedish 9 = "nio" |
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
type _bool<X, Y> = (X, Y) => X | Y; | |
let _true = <X, Y>(x: X, y: Y) => x; | |
let _false = <X, Y>(x: X, y: Y) => y; | |
let _not = <X, Y>(b: _bool<Y, X>) => (x: X, y: Y) => b(y, x); | |
let _and = <X, Y>(b1: _bool<X | Y, Y>, b2: _bool<X, Y>) => (x: X, y: Y) => b1(b2(x, y), _false(x, y)); | |
let _or = <X, Y>(b1: _bool<X, X | Y>, b2: _bool<X, Y>) => (x: X, y: Y) => b1(_true(x, y), b2(x, y)); | |
// Using | |
// let __compose = <X, Y, U, V, W>(f: (U, V) => W, g: (X, Y) => U, h: (X, Y) => V) => (x: X, y: Y) => f(g(x, y), h(x, y)); |
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
///////////////////////////////////////////////////////// | |
// Origin: https://www.youtube.com/watch?v=t1e8gqXLbsU | |
// Rewritten to Typescript by md2perpe on 25 May 2018 | |
///////////////////////////////////////////////////////// | |
///////////////////////////////////////////////////////// | |
// The interface of a monad | |
///////////////////////////////////////////////////////// |
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
# https://trinket.io/python | |
import turtle | |
L = 200 | |
turtle.speed(1000) | |
turtle.penup() | |
turtle.goto(-100, -100) | |
turtle.color("red") |
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 matching_positions(data, choices): | |
# Example: data="apabanan", choices="aan" | |
# Initialize a dictionary for all positions of the char's in choices | |
positions = {} | |
for c in choices: | |
positions[c] = [] | |
# Populate the dictionary | |
for k, c in enumerate(data): |