This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
#include <vector> | |
#include <fstream> | |
#include <functional> | |
double fp(double phi, double a, double x, double y) { | |
return std::tan(0.5 * (phi + std::atan(y / (x - a)))); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import numpy | |
def getZigZagNumber(num): | |
# 0, 1, 2番目のZig-Zag Numberは1と定義 | |
if (num == 0) or (num == 1) or (num == 2): | |
return 1 | |
else: | |
alterPerm = 0 | |
for perm in itertools.permutations(list(range(num))): | |
frontSign = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ある数より前のリストl1から選ぶよ | |
#ある数より後ろのリストはl2だよ | |
def choose_l1(l1,l2,zigzaglist): | |
global zigzagnum,write_flag | |
#前のリストがなかったら終わるよ | |
if l1==[]: | |
if l2==[]: | |
zigzagnum +=1 | |
return 1 | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inivels = (0,-1) | |
fp = open('col.dat','w') | |
def col(vels,a): | |
(u,v) = vels # u : small ball || v : large ball | |
uu = ((1-a)*u + 2*a*v)/(1+a) | |
vv = (2*u + (a-1)*v)/(1+a) | |
return (uu,vv) | |
def cols(vels,a): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
from numbers import Number | |
class Dual: | |
def __init__(self,z): | |
(self.x,self.y) = z | |
def __str__(self): | |
if self.y >= 0 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type I = Integer | |
data F3 = S [I] | SS I | |
instance Show F3 where | |
show (S x) = show x | |
show (SS x) = show x | |
sss :: [F3] -> IO I -> IO I | |
sss [] x = do | |
x' <- x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type I = Integer | |
data F3 = S [I] | SS I deriving Show | |
sss :: [F3] -> I -> I | |
sss [] _ = 0 | |
sss (S []:ns) x = sss ns x | |
sss [S [1]] x = fpow f x x where f y = y+1 | |
sss (S (1:ns):nss) x = fpow (sss (S ns:nss)) x x | |
sss (S (n:ns):nss) x = sss (S (n'++ns):nss) x where n'=replicate (fromIntegral x) (n-1) | |
sss (SS 1:nss) x = sss (S [x]:nss) x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type I = Integer | |
pfgh :: [I] -> I -> I | |
pfgh list x | null l2 = x+1 | |
| null l1 = fpow (pfgh (head list -1 : tail l2)) x x | |
| otherwise = pfgh (init l1 ++ [x] ++ (head l2 -1) : tail l2) x | |
where | |
(l1,l2) = span (<=0) list | |
fpow :: (a -> a) -> I -> (a -> a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type I = Integer | |
g :: [I] -> I -> I | |
g [] x = x-1 | |
g (0:as) x = g as (f x) where f y = y+1 | |
g (a:as) x = g (clone l1' (x+1)++l2) (x+1) | |
where | |
clone list 1 = list | |
clone list k = list ++ clone list (k-1) | |
(l1,l2) = span (a<=) as |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type I = Integer | |
type M = [I] | |
g :: (M,I) -> I | |
g ([],x) = x | |
g (0:as,x) = f$g (as,x) where f y = y+1 | |
g (a:as,x) = g (clone l1 (g (as,x))++l2,x) | |
where | |
(l1,l2) = t$span (a<=) as | |
t (lis,[]) = (lis,[]) |
NewerOlder