I hereby claim:
- I am nifo on github.
- I am nifo (https://keybase.io/nifo) on keybase.
- I have a public key ASCbWLqw8Sh3fMOU6GBupKnKYnJE-kbXnfHG0N0aHTsuewo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
Aracua Article
Writer Article
Newspilot
| def create_user_name(first_name, last_name, length=3): | |
| """The first 'length' (default 3) letters of first name and last name. Fills | |
| out with last letter in the names if less than specified length. """ | |
| return first_name.ljust(length, first_name[-1])[:length] + \ | |
| last_name.ljust(length, last_name[-1])[:length] | |
| # Examples | |
| print create_user_name('bo', 'ek') # booekk | |
| print create_user_name('niklas', 'forsstrom') # nikfor | |
| print create_user_name('bo', 'ahl') # booahl |
| from random import randint | |
| # ex. scissors and lizard is beaten by rock | |
| beaten_by = {'rock': ['scissors', 'lizard'], | |
| 'paper': ['rock', 'spock'], | |
| 'scissors': ['paper', 'lizard'], | |
| 'lizard': ['spock', 'paper'], | |
| 'spock': ['scissors', 'rock']} | |
| def rplsls_game(): |
| def password_generator(min_len= 10, max_len=18, | |
| chars='abcdefghjkmnpqrstauvz123456789ABCDEFGHIJKLMNOPQRSTUVXYZ!#$@'): | |
| "Generator of random passwords using the character set 'chars'" | |
| from random import randint | |
| length = randint(min_len,max_len) | |
| while True: | |
| yield ''.join(choice(chars) for i in range(length)) | |
| def valid_password(password, digits=0, lower_case=0, upper_case=0): |
| def valid_pnummer(pnr): | |
| """Returns True if input is a valid personnummer. | |
| Can be with or without "-" and 19~ | |
| Requirement from the swedish tax agency (2013-08-05): | |
| http://www.skatteverket.se/privat/folkbokforing/omfolkbokforing/personnumretsuppbyggnad.4.18e1b10334ebe8bc80001502.html | |
| Kontrollsiffran | |
| Fjärde siffran i födelsenumret är en kontrollsiffra. Den räknas ut | |
| maskinellt med ledning av födelsetiden och födelsenumret. |
| def anagrams(file_path, min_group_size=8): | |
| "Gets all anagrams for the file at file_path. Print outs the result if " | |
| "there are more than min_group_size (default 8) words." | |
| "A python version of:" | |
| "http://docs.oracle.com/javase/tutorial/collections/interfaces/map.html and see multimaps." | |
| m = {} | |
| with open(file_path) as file: | |
| for line in file: |