Skip to content

Instantly share code, notes, and snippets.

View wkta's full-sized avatar

moonbak ♤ wkta

View GitHub Profile
@wkta
wkta / day_1.py
Created March 3, 2014 22:41
#MonthOfCode - hello world
import random
graal = [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
binf,bsup = min(graal),max(graal)
k = 0
while( k<len(graal) ):
attempt = list()
for i in xrange(len(graal)):
attempt.append( random.randint( binf, bsup))
if (graal[k] ==attempt[k]):
print ' '.join( [chr(code) for code in attempt] )
@wkta
wkta / day_2.py
Created March 4, 2014 21:00
#MonthOfCode day 2 - border
# -*- coding: utf-8 -*-
import random
chars=[' ','┌','┐','└','┘','─','│']
N,M = 32,16
matr = list()
for i in xrange(M):
line = list()
for i in xrange(N):
line.append( random.choice( chars) );
matr.append(line)
@wkta
wkta / day_3.py
Created March 4, 2014 22:55
#MonthOfCode day 3 - binary
import string, random
print 'enter a list of movies you\'ve watched, separated by comas'
movies = string.split( raw_input() , ',')
# initializing var. for movie ranking
scores = dict();
for mov in movies:
scores[mov]={ 'won':1, 'lost':1, 'better_th':list() }
for i in xrange( int(round(len(movies)*1.5)) ): # 50% extra questions
@wkta
wkta / day_4.py
Created March 5, 2014 21:59
#MonthOfCode day 4 - error
# imports the sleep function; it will add some suspense
from time import sleep
import random
score = 0
reasonable_player = False
print '*** tough guy simulator ***'
invite_msg = 'so you want to play the russian roulette, hu?'
while(not reasonable_player):
# this inner loop aims at validating the answer
@wkta
wkta / day_5.py
Created March 6, 2014 23:05
#MonthOfCode day 5 - bounce
import os
from time import sleep
WIDTH = 32;
def old_school_disp( x_pos, velocity):
os.system('clear')# replace by os.system('cls') on windows systems
pos = int(x_pos )
for i in xrange(WIDTH):
if(pos == i ):
print 'O',
else:
@wkta
wkta / day_6.py
Created March 7, 2014 23:44
#MonthOfCode day 6 - time
from datetime import timedelta, date, datetime
import random
import time
import os
import string #for the split function
def respPositiveTo( question ):
"""
this function aims at displaying a question
& validating the Y/N answer
@wkta
wkta / day_7.py
Last active August 29, 2015 13:57
#MonthOfCode day 7 - input
import random
import sys # for exit function
import pygame
from pygame import Rect
# DEFINITIONS
################################################
BLACK = ( 0, 0, 0)
DISP_COLOR=(230, 190, 230) #gray with a violet touch
DISP_COLOR_2=(69, 0, 82) #violet
@wkta
wkta / day_8.py
Last active August 29, 2015 13:57
#MonthOfCode day 8 - mathematics
import random
import sys # for exit function
import time
import pygame
from pygame import Rect
# DEFINITIONS
################################################
DISP_COLOR=(230, 190, 230) #gray with a violet touch
PREDEF_RADIUS = 8
@wkta
wkta / day_9.py
Last active August 29, 2015 13:57
#MonthOfCode day 9 - jump
import os
import random
from time import sleep
def disp_word_letter_up( word, ind_letter=-1 ):
chars = list(word)
os.system('clear')# replace by os.system('cls') on windows systems
#upper row
for i in xrange( len(chars)):
if(ind_letter == i ):
@wkta
wkta / day_10.py
Last active August 29, 2015 13:57
#MonthOfCode day 10 - switch
# As you know there's no such thing as a switch statement in python
# but it can be easily simulated using functions
def switch_simu( val, funct_dict):
if( not val in funct_dict.keys()):
funct_dict[ 'default']()
return
funct_dict[ val]()
def below2Message():