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
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
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
vector<int> abn;
set<int> se;
int divis(int num) {
int sum = 0;
#! python
fib1 = 1
fib2 = 1
fib = 0
n = 2
while fib <= pow(10, 999):
fib = fib1 + fib2
fib1 = fib2
fib2 = fib
@touyou
touyou / file0.txt
Created March 6, 2014 00:45
第15回オフラインリアルタイムどう書くの解答 ref: http://qiita.com/touyoubuntu/items/46d82e755ad641b51661
#! python
# s2 = raw_input().split('/')
def conv(c):
if c == '0':
return 0
return 1
def solve(s1):
s2 = s1.split('/')
@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の機能使うと素数列挙簡単らしいけど…
@touyou
touyou / isGIFExtension.swift
Created April 12, 2016 09:34
NSDataがGIFかどうか判断するためのExtensionのSwift版。Objc-Cで書かれた https://gist.github.com/cathandnya/7279009 を参考にしました。
extension NSData {
func isGIF() -> Bool {
let bytes = UnsafePointer<Int8>(self.bytes)
return self.length >= 6 && (strncmp(bytes, "GIF87a", 6) == 0 || strncmp(bytes, "GIF89a", 6) == 0)
}
}