This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import collections | |
#utility functions | |
def calc_dist(dice_list,fun): | |
cntr = {i:0 for i in range(2,13)} | |
cntr.update(collections.Counter(map(fun, dice_list))) | |
if len(cntr) != 11: # discard if sums outside of range(2,13) are generated | |
return ['== WRONG == ']*11 | |
return ['{: >3} : {: >5.2f}%'.format(k,100*v/len(dice_list)) for k,v in cntr.items()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## First ########################################## | |
mystery = iter('') | |
# challenge code | |
def print_stuff(stuff): | |
if stuff: | |
print "Printing some stuff" | |
for x in stuff: | |
print x | |
else: | |
print "Nothing to print" |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
print(requests.put('http://localhost:8000/test',data={'txt':'Hello World'}).json()) | |
# prints "success" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
""" | |
"option definitions" and "time definitions could also have been placed in extra files and imported. | |
""" | |
#----------------------- | |
#- Option Definitions: - | |
#----------------------- | |
options = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import shutil | |
DIR = '/home/dani/bin/dota_2_items/' | |
html = requests.get('https://dota2.gamepedia.com/Items').text | |
s = BeautifulSoup(html, 'html.parser') | |
mark = s.find('span', id="Items") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
def is_unique(seq, symbols): | |
r = [el for el in seq if el in symbols] | |
return len(r) == len(set(r)) | |
def rule_row_unique(board, symbols): | |
return all(is_unique(row, symbols) for row in board) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer