Skip to content

Instantly share code, notes, and snippets.

View touyou's full-sized avatar
💻
Develop Design

Fujii Yosuke touyou

💻
Develop Design
View GitHub Profile
@touyou
touyou / loop.py
Created November 22, 2010 13:45
python
#! /usr/bin/env python
# -*-coding:utf-8-*-
def main():
i = input()
while True:
i = i*i
if i >= 10^100:
return False
@touyou
touyou / uruu.py
Created November 22, 2010 14:19
python
#! /usr/bin/env python
def main():
while True:
year = input("年を入力:")
if year % 4 == 0 and not year % 100 == 0 or year % 400 == 0:
print year,"年は閏年です。"
else if year == none:
break
else:
@touyou
touyou / nijihou.py
Created November 23, 2010 01:18
python
#! /usr/bin/env python
def nroot(a, n, x=1.0, eps=1e-7):
while abs(a - x**n) > eps:
x = ( (n-1)*x + a/(x**(n-1)) ) / n
return x
def main():
print "aX^2+bX+c=0"
while True:
@touyou
touyou / chap1.java
Created November 23, 2010 09:28
Java
class chap1 {
public static void main(String[] args) {
System.out.print("abc");
System.out.print("def"+"ghi");
System.out.println("jkl\nxyz");
}
}
@touyou
touyou / p57.py
Created September 17, 2012 12:23
漸化式を調べてやりました
#!/usr/bin/env python
# coding: utf-8
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a%b)
a = 1
@touyou
touyou / p69.py
Created September 29, 2012 14:30
dailycoding 2012/9/29
#! /usr/bin/env python
# coding: utf-8
# φ (n) を調べる -> wikiでこんな公式みつける φ (n) = n * Π (1 - 1/Pk)
# 変形して φ (n) / n = Π (1 - 1/Pk) の最小 -> 1 - 1/Pk < 1なのでkが大きいほど
# 小さいことがわかる
# P1P2...Pk<=1000000を探しませう
# Pythonの機能使うと素数列挙簡単らしいけど…
import UnityEngine
class BallController(MonoBehaviour):
public Speed as single = 20.0f
def Start():
rigidbody.AddForce((transform.forward+transform.right) * Speed, ForceMode.VelocityChange)
def Update():
pass
import UnityEngine
class Player (MonoBehaviour):
public speed as single = 8.0f
public gravity as single = 10.0f
public controller as CharacterController
public jumpSpeed as single = 6.0f
public moveDirection as Vector3
@touyou
touyou / p17.py
Last active August 29, 2015 13:56
project euler solution --- problem 17
#! python
l1 = ['one','two','three','four','five','six','seven','eight','nine']
l2 = ['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']
l3 = ['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']
l4 = ['hundred', 'thousand', 'and']
ans = 0
for i in l1:
ans = ans + len(i)
@touyou
touyou / p19.py
Created February 27, 2014 14:59
project euler solution -- problem 19
#! python
ndays = [31,28,31,30,31,30,31,31,30,31,30,31]
ldays = [31,29,31,30,31,30,31,31,30,31,30,31]
day = 0 # 0--Monday --> 6--Sunday
ans = 0
def isleap(year):
if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):
return True