Skip to content

Instantly share code, notes, and snippets.

# coding: utf8
print [x for x in range(1900, 2201) if x%4 == 0 and x%100 != 0 or x%400 == 0]
# coding: utf8
def isLeapYear(x):
return x%4 == 0 and x%100 != 0 or x%400 == 0
# coding: utf8
import a2
import csv
reader = csv.DictReader(open("evaluation-values.csv"))
leapAvg = 0
leapNum = 0
nonLeapAvg = 0
@takuma7
takuma7 / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
puts "Hello World"
(* Sort list of polynomial functions (fs) based on degree of x in ascending order *)
SortByDegree[fs_, x_] := Module[{},
Comp[f1_,f2_] := Exponent[f1,x] < Exponent[f2,x];
Sort[fs,Comp]
];
(* Calculate pseud-remainder *)
Rem[f_, g_, x_] := Module[{q,r,u},
{q,r} = Together[#]&/@PolynomialQuotientRemainder[f,g,x];
u = PolynomialLCM[Denominator[q], Denominator[r]];
#include <stdio.h>
int main(void){
printf("Hello World!\n"); //this is a test
}
@takuma7
takuma7 / gist:640516
Created October 22, 2010 13:18
Project Euler - Problem 1
import System.IO
main = do
putStrLn $ show $ sum $ filter judge [1..999]
judge a | a `mod` 3 == 0 || a `mod` 5 == 0 = True
| otherwise = False
@takuma7
takuma7 / gist:640522
Created October 22, 2010 13:24
Project Euler - Problem 2
import System.IO
main = do
putStrLn $ show $ sum $ filter even $ takeWhile ((>) 4000000) fib
fib = 1:2:[ a+b | (a,b) <- zip fib (tail fib)]