Skip to content

Instantly share code, notes, and snippets.

#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
void reverse(char *str){
char* end = str;
char tmp;
if(str){
@yasuharu519
yasuharu519 / Problem1_1.cpp
Last active December 11, 2015 06:08
CrackingTheCodeInterviewProblem1.1
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
char c;
bool chars[256];
bool dup_flag = false;
# -*- coding:utf-8 -*-
def isCyclicNum(num):
if str(num) == str(num)[::-1]:
return True
else:
return False
def main():
ans = 0
# -*- coding:utf-8 -*-
prime_number = list()
def function(num):
count = largest = 1
while num != 1:
count += 1
if any([count % x == 0 for x in prime_number]):
continue
@yasuharu519
yasuharu519 / ProjectEulerNo2.py
Created July 24, 2012 00:51
Project Euler No.2
def generateFib():
a = 1
b = 2
while a < 4000000:
a, b = b, a + b
if a % 2 == 0:
yield a
else:
continue
@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())
@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 / 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 / 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 / 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値のタプルを入力とし、使われている数字をリストで返す