Skip to content

Instantly share code, notes, and snippets.

View halexus's full-sized avatar

Alexander Thaller halexus

View GitHub Profile
def part_seq(seq, size):
"""Split a sequence in parts of length size and return
a list of lists where the latter have length size.
"""
assert len(seq)>0
parts = []
for i in range(0,len(seq), size):
parts.append(seq[i:i+size])
return parts
@halexus
halexus / More Functional (map, fold).py
Created January 19, 2012 07:46
One line solutions (without imports) in Python2 to Lambdaheads 2012-01-09 challenge https://metalab.at/wiki/Lambdaheads
from itertools import permutations
print '|'.join(map(''.join, reduce(lambda x, y: x | y, [set(permutations(("YYYY", "MM", "DD"), i)) for i in range(1,4)] + [set(permutations(("YY", "MM", "DD"), i)) for i in range(1,4)])))
@halexus
halexus / Beispiel 4.py
Created March 8, 2019 08:14
Python Lösung Beispiel 4 Wahrscheinlichkeitstheorie
from itertools import product # Kartesisches Produkt
from fractions import Fraction # Brüche
def X1(w): # Augenzahl erster Würfel
return w[0]
def X2(w): # Augenzahl zweiter Würfel
return w[1]
omega = list(product(range(1,7), range(1,7))) # Ergebnismenge
@halexus
halexus / Beispiel 4.ipynb
Created March 12, 2019 21:35
Lösung mit Python von Beispiel 4 Wahrscheinlichkeitstheorie
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@halexus
halexus / Beispiel 10.ipynb
Last active March 15, 2019 10:43
Python Lösung von Beispiel 10 Wahrscheinlichkeitstheorie
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@halexus
halexus / Beispiel 15.ipynb
Last active March 24, 2019 09:34
Aufgabe 15 der UE Wahrscheinlichkeitstheorie
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@halexus
halexus / Beispiel 16.ipynb
Created March 24, 2019 16:33
Beispiel 16 UE Wahrscheinlichkeitstheorie
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@halexus
halexus / Beispiel 21.ipynb
Created March 31, 2019 20:07
Beispiel 21 UE Wahrscheinlichkeitstheorie
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@halexus
halexus / Beispiel 22.ipynb
Created April 3, 2019 15:21
Beispiel 22 UE Wahrscheinlichkeitstheorie
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@halexus
halexus / Beispiel 23.ipynb
Last active April 7, 2019 08:16
Aufgabe 23 UE Wahrscheinlichkeitstheorie
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.