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
# 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}) |
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
#!/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]] |
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
#!/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): |
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
#!/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))}") |
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
#!/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 |
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/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() |