Skip to content

Instantly share code, notes, and snippets.

View kostasdizas's full-sized avatar

Kostas Dizas kostasdizas

  • Torstone Technology
View GitHub Profile
@kostasdizas
kostasdizas / lottery_coupons.py
Last active December 1, 2017 00:23
Weighted Lottery entry calculator
rules = [(1,100,1),(101,500,2), (501,1000,3), (1001,1500,4)]
tickets = 993.9
entries = round(sum([(b-a+1)/c if (tickets>b) else (tickets-a+1)/c for a,b,c in rules if tickets>a]))
print('You have {} entries'.format(entries))
@kostasdizas
kostasdizas / introretrospection.py
Created August 4, 2017 11:19
introretrospection.py
class Foo(object):
def whoami(self):
return [k for k,v in globals().iteritems() if v is self]
def whoarewe(self):
return [k for k,v in globals().iteritems() if isinstance(v, type(self))]
f = Foo()
b = Foo()
@kostasdizas
kostasdizas / tricks.py
Last active January 13, 2017 04:29
Calculator tricks
join_digits = lambda i, j: int(str(i) + str(j))
def do_the_thing(a, b):
for i in range(b):
print("{} × {:02d} = {:10d}".format(a, join_digits(i, b-i), a * join_digits(i, b-i)))
do_the_thing(12345679, 9)
@kostasdizas
kostasdizas / prime.py
Created January 3, 2017 20:39
Regex Prime
import re
def is_prime(n):
return not re.match(".?$|(..+?)\1+$", "0" * n)
@kostasdizas
kostasdizas / readme.md
Created December 25, 2016 22:49
Fibinaries and Pribinaries

#Fibinaries and Pribinaries

Silly script to create numbers in a positional notation using the fibonacci sequence and prime numbers as bases.

@kostasdizas
kostasdizas / numbers-words-lengths.py
Created September 10, 2016 21:45
Greek number word length chains
# coding=utf-8
import matplotlib.pyplot as plt
def numToWords(num, join=True):
'''words = {} convert an integer number into words'''
units = ['','ένα','δύο','τρία','τέσσερα','πέντε','έξι','επτά','οκτώ','εννέα']
teens = ['','έντεκα','δώδεκα','δεκατρία','δεκατέσσερα','δεκαπέντε','δεκαέξι', \
'δεκαεπτά','δεκαοκτώ','δεκαεννέα']
tens = ['','δέκα','είκοσι','τριάντα','σαράντα','πενήντα','εξήντα','εβδομήντα', \

Keybase proof

I hereby claim:

  • I am kostasdizas on github.
  • I am kostasdizas (https://keybase.io/kostasdizas) on keybase.
  • I have a public key ASBvB6OGtJhEA1OzKc9E0G6SDS2mpwzAAIWZArTHQXsChwo

To claim this, I am signing this object:

1^2 = 1(1+1)/2 = 1
6^2 = 8(8+1)/2 = 36
35^2 = 49(49+1)/2 = 1225
204^2 = 288(288+1)/2 = 41616
1189^2 = 1681(1681+1)/2 = 1413721
6930^2 = 9800(9800+1)/2 = 48024900
40391^2 = 57121(57121+1)/2 = 1631432881
#include <stdio.h>
#include <stdbool.h>
#define MAX_QUEUE_SIZE 15
#define ITEM_LENGTH 32
typedef char queue_element_t [ITEM_LENGTH];
typedef struct circular_queue_t {
int front;
@kostasdizas
kostasdizas / adastral.py
Created April 28, 2016 11:44
Adastral Hub Menu
#!/usr/bin/env python
"""
Find the Adastral Park Hub Menu
"""
from __future__ import print_function
import re
import webbrowser