Skip to content

Instantly share code, notes, and snippets.

# CSV was funktioniert
import pandas as pd
df = pd.read_csv("D:\Python\Vokabeltrainer\englisch.csv",
sep=";",
header=0,
#encoding = "latin1", sollte Umlaute anpaasen, aber zerstört sie
names=["Deutsch",
"Englisch"],
dtype = {"Deutsch":str,
"Englisch":str})
@Tomalak
Tomalak / day9.py
Last active December 14, 2021 14:14 — forked from spielkind/day9.py
#!/bin/python
# https://adventofcode.com/2020/day/9
with open('day9.txt') as f:
heightmap = [list(map(int, line.strip())) for line in f]
H, W = len(heightmap), len(heightmap[0])
COORDS = [(x, y) for y in range(H) for x in range(W)]
value_at = lambda p: heightmap[p[0]][p[1]]
@Tomalak
Tomalak / day5.py
Last active December 5, 2021 17:40 — forked from spielkind/day5.py
#!/bin/python
# solution for https://adventofcode.com/2021/day/5
data = []
with open('day5.txt') as f:
for line in f:
data.append([tuple(map(int, c.split(','))) for c in line.strip().split(' -> ')])
def get_line_points(pair):
@Tomalak
Tomalak / day1.py
Last active December 2, 2021 18:12 — forked from spielkind/day1.py
#!/bin/python
with open('day1.txt') as f:
measurements = list(map(int, f))
def compare(values):
return [m for i, m in enumerate(values) if i and m > values[i-1]]
print(f"Part One: {len(compare(measurements))}")
@Tomalak
Tomalak / day2.py
Last active December 2, 2021 17:55 — forked from spielkind/day2.py
#!/bin/python
class Submarine():
def __init__(self):
self.horizontal = 0
self.depth = 0
self.aim = 0
def forward(self, amount):
self.horizontal += amount
self.depth += amount * self.aim
@Tomalak
Tomalak / nexus.py
Last active December 27, 2015 15:09
#!/usr/bin/env python
import urllib, re
from collections import OrderedDict
url = 'https://play.google.com/store/devices'
data = urllib.urlopen(url).read()
matches = re.findall(r'\bNexus \d+', data)
devices = OrderedDict.fromkeys(matches).keys()