Skip to content

Instantly share code, notes, and snippets.

View yasuharu519's full-sized avatar
💪

Yasuharu Sawada yasuharu519

💪
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# お題: 時間帯重複チェック
def checkIfSyntax(time1, time2):
"""
>>> checkIfSyntax((-2,3,1,1,), (1,1,1,1))
Traceback (most recent call last):
...
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
N = 10000
def main():
numList = range(1, N + 1)
# 1を除く
numList.pop(0)
@yasuharu519
yasuharu519 / TimeDuplicationCheck2.py
Created April 6, 2011 09:07
check if the time is duplicated. if it is duplicated, this code returns the part of the time which is duplicated. see -> http://d.hatena.ne.jp/fumokmm/20110329/1301403400#20110329f1
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# お題: 時間帯重複チェック(応用編)
def CheckIfSyntax(*timeTuple):
for i in xrange(len(timeTuple)):
(timeStartHour, timeStartMin, timeEndHour, timeEndMin) = timeTuple[i]
# 時間の書式のチェック
if timeStartHour > 24 or timeEndHour > 24 \
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import json
API_KEY = ""
class GoogleURLShorter(object):
def __init__(self, target_url, api_key=""):
self.baseUrl = 'https://www.googleapis.com/urlshortener/v1/url'
@yasuharu519
yasuharu519 / play_itunes_album_with_afplay.py
Created April 10, 2011 14:20
this script is to play itunes album using afplay
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ファイルとサブディレクトリのパスを表示
MUSIC_PATH = u"/Users/USERNAME/Music/iTunes/iTunes Media/Music"
import glob
import os
from unicodedata import normalize
from subprocess import call
@yasuharu519
yasuharu519 / check_number_set.py
Created July 26, 2011 17:00
1~9の数を一度だけ使って、□□□□ × □ = □□□□ を満たす式を考える
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# □□□□ × □ = □□□□
# として、□の中に1~9の数字が一つずつ入る時の組合せ
# 1000~9999 * 1~9 を総当りで確かめてみるか → パソコンの力任せ
# (a, b, c) で組合せを表現
# 3値のタプルを入力とし、使われている数字をリストで返す
@yasuharu519
yasuharu519 / GoogleCodeJamJapan2011problemA.py
Created October 12, 2011 14:16
GoogleCodeJamJapan2011 予選 問題A.カードシャッフル
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def _test():
import doctest
doctest.testmod()
def cut(cardList, fromA, toB):
"""
>>> a = [1]
@yasuharu519
yasuharu519 / GoogleCodeJamJapan2011problemClarge.py
Created October 12, 2011 14:31
GoogleCodeJamJapan2011 予選 問題C.ビット数
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from problemC import process as correct
def file_open(filename):
T = 0
caseList = []
with open(filename) as f:
T = int(f.readline().strip())
@yasuharu519
yasuharu519 / GoogleCodeJamJapan2011FinalproblemBsmall.py
Created October 12, 2011 15:11
GoogleCodeJamJapan2011 決勝 問題B.バクテリア増殖
#!/usr/bin/env python
# -*- coding:utf-8 -*-
def file_open(filename):
T = 0
caseList = []
with open(filename) as f:
T = int(f.readline().strip())
for i in range(T):
value = [int(x) for x in f.readline().strip().split()]
@yasuharu519
yasuharu519 / GoogleCodeJamJapan2011FinalproblemA.py
Created October 12, 2011 15:12
GoogleCodeJamJapan2011 決勝 問題A.アンテナ修復
#!/usr/bin/env python
# -*- coding:utf-8 -*-
def file_open(filename):
T = 0
caseList = []
with open(filename) as f:
T = int(f.readline().strip())
for i in range(T):
key = int(f.readline().strip())