Skip to content

Instantly share code, notes, and snippets.

View falsetru's full-sized avatar

이정민(Jeong-Min Lee) / SWAT falsetru

View GitHub Profile
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)
(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)))
(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)))
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)
@falsetru
falsetru / code-kata-pickakin.py
Created April 12, 2012 02:54
code-kata-pickakin
# 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:
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)
@falsetru
falsetru / submit.py
Last active December 13, 2015 11:38
submit solution to algospot judge.
#!/usr/bin/env python
import cookielib
import os
from contextlib import closing
import re
import getpass
import webbrowser
import sys
#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),
import collections
import sys
def is_valid_fastq(lines):
return (
lines[0].startswith('@') and
lines[2].startswith('+') and
len(lines[1]) == len(lines[3])
)
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')