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
from Tkinter import * | |
from math import hypot | |
class CircleDrawing: | |
def __init__(self, canvas): | |
self.canvas = canvas | |
def click(self, e, color): | |
self.color = color | |
self.center = e.x, e.y | |
self.obj_id = self.canvas.create_oval(e.x, e.y, e.x, e.y, outline=color) |
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
(define H 300) | |
(define r (/ H 2)) | |
(define (ypos x) | |
(if (<= x 1) | |
(/ (sqrt (- 1 (sqr (- (* 2 x) 1)))) 2) | |
(/ (sqrt (- 1 (sqr (- (* 2 x) 3)))) -2))) | |
(define (ypos-as-posn x) | |
(make-posn (* x r) | |
(* (+ 1 (ypos x)) r))) |
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
(define H 500) | |
(define r (/ H 2)) | |
(define (ypos x) | |
(if (<= x 1) | |
(/ (sqrt (- 1 (sqr (- (* 2 x) 1)))) 2) | |
(/ (sqrt (- 1 (sqr (- (* 2 x) 3)))) -2))) | |
(define (ypos-as-posn x) | |
(make-posn (* x r) | |
(* (+ 1 (ypos x)) r))) |
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
from Tkinter import * | |
from math import hypot | |
class CircleDrawing: | |
def __init__(self, canvas): | |
self.canvas = canvas | |
def click(self, e, color): | |
self.color = color | |
self.center = e.x, e.y | |
self.obj_id = self.canvas.create_oval(e.x, e.y, e.x, e.y, outline=color) |
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
# http://ilker.de/code-kata-pickakin | |
def dsq(product_code): | |
return product_code[0] | |
def partition(common_dsq, orig_list): | |
new_list = set() | |
akin_list = set() | |
for x in orig_list: | |
if dsq(x) in common_dsq: |
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
from functools import lru_cache | |
coins= 10,20,50,100,200,500,1000,2000,5000,10000 | |
@lru_cache(None) | |
def count(amount, idx=len(coins)-1): | |
if amount < 0 or idx < 0: return 0 | |
if amount == 0: return 1 | |
return count(amount - coins[idx], idx) + count(amount, idx-1) |
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
#!/usr/bin/env python | |
import cookielib | |
import os | |
from contextlib import closing | |
import re | |
import getpass | |
import webbrowser | |
import sys |
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
#include <stdio.h> | |
#include <algorithm> | |
#define swc(i) (1L << (i * 3)) | |
long long switches[10] = { | |
swc(0) | swc(1) | swc(2), | |
swc(3) | swc(7) | swc(9) | swc(11), | |
swc(4) | swc(10) | swc(14) | swc(15), | |
swc(0) | swc(4) | swc(5) | swc(6) | swc(7), | |
swc(6) | swc(7) | swc(8) | swc(10) | swc(12), |
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 collections | |
import sys | |
def is_valid_fastq(lines): | |
return ( | |
lines[0].startswith('@') and | |
lines[2].startswith('+') and | |
len(lines[1]) == len(lines[3]) | |
) |
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 lxml.html | |
import requests | |
FILENAME = '3.png' | |
r = requests.get('http://www.onlinebarcodereader.com/') | |
root = lxml.html.fromstring(r.text) | |
MAX_FILE_SIZE, = root.cssselect('input[name=MAX_FILE_SIZE]') | |
senderid, = root.cssselect('#senderid') |