Skip to content

Instantly share code, notes, and snippets.

Thomas Iwaszko wkta

  • France
Block or report user

Report or block wkta

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View verbose_baseconv.py
num_tested = int(input())
while num_tested < 1:
num_tested = int(input())
print("= ", end='')
is_first_print = True
total =0 ; c = 0 ; K = 1
while K < num_tested:
c += 1 ; K = 1<<c
for n in range(K):
prod = num_tested&(1<<n);
@wkta
wkta / day_31.py
Created Mar 31, 2014
#MonthOfCode day 31 - exit
View day_31.py
# a dumb game. How to win this?
import random
import time
import sys
t0 = time.time()
while True:
if random.choice((True,False)):
time.sleep(0.13)
else:
time.sleep(0.29)
@wkta
wkta / day_30.py
Created Mar 31, 2014
#MonthOfCode day 30 - infinity
View day_30.py
import pygame
from time import sleep
import random
from math import cos,sin,pi
DISP_WIDTH = 800
DISP_HEIGHT = 600
class Player:
'''models a moving player representation that can move left or right'''
BASECOLOR = pygame.Color('darkred')
@wkta
wkta / day_29.py
Created Mar 31, 2014
#MonthOfCode day 29 - golf
View day_29.py
from random import choice
mid_names = [ "" for i in xrange(7) ]
mid_names.extend( [ "Kindred", "Junior", "Senior", "Jack" ])
first_names = \
[ "Tiger", "Mike", "Edgar", "Jean-Paul", "Sandra", "Clara", "Gary", "Philip", "Edwin" ]
last_names = [ "Woods", "Jackson", "Nelson", "Watson", "Palmer", "Hagen", "Nicklaus", "Haeger", "de LaMartre" ]
def printRandomName():
mid = choice(mid_names)
@wkta
wkta / day_28.py
Created Mar 31, 2014
#MonthOfCode day 28 - race
View day_28.py
import random
import time
def detPrecision( candidate, model):
chars_cand = list( candidate)
chars_model = list(model)
while( len(chars_cand)<len(chars_model) ):
chars_cand.append(' ')
while( len(chars_cand)>len(chars_model) ):
chars_cand.pop()
@wkta
wkta / day_27.py
Created Mar 31, 2014
#MonthOfCode day 27 - pattern
View day_27.py
import re
print "Testing your knowledge on regular expressions"
partterns = [
"a{4,}b", "Y.*g", "ro..c..ter", "[a,m,k]{5,8}" ]
for pat in partterns:
print "Try to type a string that matches the REGULAR EXPRESSION",pat
success = False
while True:
user_str = raw_input()
@wkta
wkta / day_26.py
Created Mar 31, 2014
#MonthOfCode day 26 - malicious
View day_26.py
# this code is awesome, you will see it everywhere!
import sys
import random
import os
alphabet = [chr(i) for i in range(ord('a'),ord('z') + 1) ]
def genRandomName():
name_length = random.randint(2,8)
lchar = list()
for i in xrange(name_length):
@wkta
wkta / day_25.py
Created Mar 31, 2014
#MonthOfCode day 25 - cursor
View day_25.py
import pygame
DISP_WIDTH = 640
DISP_HEIGHT = 480
def refreshScreen():
window.fill( pygame.Color('black') )
pygame.display.flip()
# init. pygame libr; create the screen and diplays a help message in the console
@wkta
wkta / day_24.py
Created Mar 31, 2014
#MonthOfCode day 24 - space
View day_24.py
import pygame
from time import sleep
import random
from math import cos,sin,pi
DISP_WIDTH = 800
DISP_HEIGHT = 600
class MobileElement:
MOMENTUM = 0.985
'''abstract class representing something that moves'''
@wkta
wkta / day_23.py
Created Mar 30, 2014
#MonthOfCode day 23 - meta
View day_23.py
# This shows how we can define and use a META-function in python
def produce_incrementor( step):
''' it produces various increment functions'''
return lambda u:u+step
print "three by three"
increm_three = produce_incrementor(3)
k=0
while k < 34:
You can’t perform that action at this time.