Skip to content

Instantly share code, notes, and snippets.

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()]
## 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.
@fuzzy-focus
fuzzy-focus / API-client.py
Created January 17, 2017 08:20
Hug Put Demo
import requests
print(requests.put('http://localhost:8000/test',data={'txt':'Hello World'}).json())
# prints "success"
#!/bin/env python
"""
"option definitions" and "time definitions could also have been placed in extra files and imported.
"""
#-----------------------
#- Option Definitions: -
#-----------------------
options = {
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")
@fuzzy-focus
fuzzy-focus / sudoku.py
Last active February 28, 2018 13:05
Solver for Sudoku-like puzzles with (more or less) arbitrary rules
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)
@fuzzy-focus
fuzzy-focus / fill_board_with_tiles.ipynb
Created March 3, 2018 17:32
place tiles on a board
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fuzzy-focus
fuzzy-focus / well_well_well.ipynb
Created March 6, 2018 12:41
Well Well Well - Daily Challenge
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fuzzy-focus
fuzzy-focus / well_well_well.ipynb
Last active March 6, 2018 13:50
Well Well Well - Daily Challenge
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.