Skip to content

Instantly share code, notes, and snippets.

View Surgo's full-sized avatar
🛰️
Generating...

Kosei Kitahara Surgo

🛰️
Generating...
View GitHub Profile
@Surgo
Surgo / gist:1047271
Created June 26, 2011 05:15
/proc/cpuinfo@dotcloud
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 26
model name : Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
stepping : 5
cpu MHz : 2666.760
cache size : 8192 KB
fpu : yes
fpu_exception : yes
@Surgo
Surgo / fizzbuzz.py
Created June 13, 2011 03:17
fizzbuzz@CodeEval
# -*- coding: utf-8 -*-
#!/usr/bin/env python
"""Usage: ./fizzbuzz.py <filename>"""
def fizzbuzz(f, b, l):
return [(i % f == 0 and 1 or 0) * 'F' \
+ (i % b == 0 and 1 or 0) * 'B' \
or '%d' % i \
@Surgo
Surgo / bash_completion
Created June 5, 2011 03:19
bash_completion for mercurial and git
sudo curl -o /opt/local/etc/bash_completion.d/mercurial "http://selenic.com/hg/raw-file/cd31a1cc1521/contrib/bash_completion"
sudo curl -o /opt/local/etc/bash_completion.d/git "http://git.kernel.org/?p=git/git.git;a=blob_plain;f=contrib/completion/git-completion.bash;hb=HEAD"
@Surgo
Surgo / dotcloud.bat
Created June 2, 2011 05:44
dotcloud.cli on Windows
@echo off
REM Save this file to /path/to/python/scripts
python -c "from dotcloud.cli import cli;cli.main()" %*
@Surgo
Surgo / srm500_div2_level2.py
Created March 24, 2011 03:29
SRM500 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM500 - div2 - level two
N friends (numbered from 0 to N-1) play a game called Mafia.
The exact rules of the game are not important for this problem.
What's important is that at some point in the game they will
need to choose one player who will lose and leave the game.
@Surgo
Surgo / srm498_div2_level2.py
Created March 5, 2011 05:11
SRM498 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM498 - div2 - level two
Fox Ciel likes sequences. One day, she invented
a new type of sequence and named it the fox sequence.
A sequence seq containing N elements is called a fox
sequence if and only if there exist four integers
a, b, c and d such that 0 < a < b <= c < d < N-1
@Surgo
Surgo / srm480_div2_level2.py
Created February 24, 2011 09:35
SRM480 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM480 - div2 - level two
TopCoder Security Agency (TSA, established today) is going
to search for dangerous content in the internet.
There are N candidate websites numbered 0 through N-1. Each
website has an address given as address[i]. It also has one
@Surgo
Surgo / srm481_div2_level2.py
Created February 23, 2011 04:16
SRM481 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM481 - div2 - level two
This time, instead of solving an easy problem with a
known solution, you will be in charge in solving an
old problem with a solution which was unknown to
this date. The old question is whether the egg or
the chicken came first. This question has been very
@Surgo
Surgo / srm482_div2_level2.py
Created February 21, 2011 12:23
SRM482 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM482 - div2 - level two
A hallway is filled with lockers numbered 1 through N,
initially all closed. Out of boredom, Dave and Earl
decide to open all the lockers. They make multiple
passes through the hallway, each beginning at locker 1.
On the first pass, they open the first unopened locker,
@Surgo
Surgo / srm483_div2_level2.py
Created February 20, 2011 02:38
SRM483 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM483 - div2 - level two
Elly and some of her friends (possibly none) are going
to the movies. Their company consists of numFriends people,
including Elly. Since they don't want to be spread across
the entire hall, they decided to sit either in the same
row or in the same column (though not necessarily next