Skip to content

Instantly share code, notes, and snippets.

View beltiras's full-sized avatar

Árni St. Steinunnarson beltiras

  • Leiguskjól
  • Reykjavík, Iceland
View GitHub Profile
@beltiras
beltiras / sll.py
Last active April 15, 2019 20:51 — forked from gunnarig/sll.py
class SLL_Node:
def __init__(self, data, next):
self.data = data
self.next = next
# IMPLEMENT THIS
def average_of_list(head):
if type(head) == float:
return head
@beltiras
beltiras / clock.py
Last active October 23, 2018 18:45 — forked from gunnarig/clock.py
class Clock:
def __init__(self,hours = 0,minutes = 0,seconds = 0):
self.hours = hours
self.minutes = minutes
self.seconds = seconds
def add_clocks(self,var1,var2,var3):
self.seconds = self.seconds + var3
if self.seconds > 59:
self.seconds -= 60
@beltiras
beltiras / oifeho.py
Created October 18, 2018 15:30 — forked from gunnarig/oifeho.py
RANK = 0
NAME = 1
COUNTRY = 2
POINTS = 3
BIRTH_YEAR = 4
def get_input(user_prompt):##
user_input = input(user_prompt)
@beltiras
beltiras / ipfehoe.py
Last active October 14, 2018 22:43 — forked from gunnarig/ipfehoe.py
list_of_list = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
def make_diagonal(list_of_lists):
diag = []
diag.append([list_of_lists[len(list_of_lists)-x-1][x] for x in range(len(list_of_lists))])
diag.append([list_of_lists[x][x] for x in range(len(list_of_lists))])
print(diag)
@beltiras
beltiras / old.py
Last active October 14, 2018 21:23 — forked from gunnarig/old.py
def make_col(a_list_of_lists):
col_list = []
n = len(a_list_of_lists)
for n in range(len(a_list_of_lists)):
col = [l[n] for l in a_list_of_lists]
col_list.append(col)
print(col_list)
return col_list
@beltiras
beltiras / pifhwe0i.py
Last active October 14, 2018 21:16 — forked from gunnarig/pifhwe0i.py
def user_input_dimentions():
not_correct_input = True
while not_correct_input == True:
try:
boardDimentions = int(input("enter width of board: "))
not_correct_input = False
except ValueError:
print("please stop being an idiot")
return boardDimentions
@beltiras
beltiras / pypp.py
Last active October 11, 2018 18:18 — forked from gunnarig/pypp.py
def menu_selection():
try:
print("Menu:")
choice = str(input("add(a), remove(r), find(f):" )).lower
except ValueError:
print("please follow the directions above")
return choice
def execute_selection(choice, a_dict):
if choice == "a":
@beltiras
beltiras / faf.py
Last active October 8, 2018 18:37 — forked from gunnarig/faf.py
def get_word_string(user_file):
user_file = open(user_file,"r")
states = []
#wordString = '' # start with an empty string of words
lines = user_file.readlines()
header = lines[0].split(",")
for line in lines[0:]:
items = line.split("\n")
states.append(items)
#print(states)
@beltiras
beltiras / ppp.py
Last active October 8, 2018 15:51 — forked from gunnarig/ppp.py
def get_word_string(user_file):
user_file = open(user_file,"r")
states = {}
#wordString = '' # start with an empty string of words
lines = user_file.readlines()
header = lines[0].split(",")
for line in lines[1:]:
items = line.split(",")
states[items[0]] = dict(zip(header[1:], items[1:])))
@beltiras
beltiras / ppp.py
Last active September 24, 2018 14:44 — forked from gunnarig/ppp.py
from fractions import Fraction
# shares price
def sharesXprice(stock,valiue):
result = stock*valiue
divide = valiue % 1
dollar = int(valiue)
print("{0} shares with market price {1} {2} have valiue ${3}".format(shares,dollar,divide,result))