Skip to content

Instantly share code, notes, and snippets.

View dencorg's full-sized avatar

Dennis Rodis dencorg

View GitHub Profile
@dencorg
dencorg / keybindings.json
Created August 2, 2023 21:07
keybindings.json
// Place your key bindings in this file to override the defaults
[
{
"key": "cmd+r",
"command": "workbench.action.gotoSymbol"
},
{
"key": "cmd+;",
"command": "cursorLineEnd"
}
# Advent of code 2019 6 solution
# using anytree ([https://anytree.readthedocs.io/en/latest/](https://anytree.readthedocs.io/en/latest/))
from collections import defaultdict
from anytree import Node, Walker
orbit_map = defaultdict(list)
orbit_set = set()
orbit_tree = {}
# δημιουργία κλάσης
class Vehicle:
def __init__(self, number_of_wheels, fuel_type, maximum_velocity):
self.number_of_wheels = number_of_wheels
self.type_of_tank = fuel_type
self.maximum_velocity = maximum_velocity
def make_noise(self):
print('VRUUUUUUUM')
@dencorg
dencorg / dicts.py
Last active October 20, 2017 23:14
prices = { 'milk': 3.67, 'bread': 1.67, 'cheese': 4.67 }
print(prices)
print(prices['milk'])
# προσθήκη ζεύγους κλειδιού τιμής
prices['butter'] = 1.95
# διαγραφή στοιχείου
del prices['butter']
@dencorg
dencorg / lists.py
Last active October 20, 2017 22:39
colors = ['red','green','blue', 'yellow']
a_list = [] # κενή λίστα
whatever = ['abc', 4.56, [2,3], 'def', 6]
print(whatever)
print(colors[0]) # 'red'
print(colors[1]) # 'green'
print(colors[-1]) # 'yellow'
word = 'Python'
# ο πρώτος χαρακτήρας
print(word[0])
# ο δεύτερος χαρακτήρας
print(word[1])
print(word[2])
print(word[3])
def add(a, b):
c = a + b
return c
print(add(2, 3))
def find_min(a,b):
if a < b:
return a
@dencorg
dencorg / loops.py
Last active October 20, 2017 11:17
num = int(input("X: "))
# έξοδος με μηδέν
while num != 0:
print(1/num)
num = int(input("X: "))
# έξοδος με break
while True:
num = int(input("X: "))
max = 10
x = 50
if x > max:
print('μεγαλύτερο')
else:
print('μικρότερο')
if x > max:
max = x
2 + 2
# 4
50 - 5*6
# 20
(50 - 5*6) / 4
# 5.0
8 / 5