Skip to content

Instantly share code, notes, and snippets.

#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)]
@takuma7
takuma7 / gist:641677
Created October 23, 2010 02:07
Project Euler - Problem 3
import System.IO
main = do
putStrLn $ show $ last $ filter ((== 0) . (mod 600851475143)) (takeWhile (< (truncate (sqrt 600851475143))) prime)
prime = 2:f [3] [3,5..]
where f (x:xs) ys = let (ps, qs) = span (< x^2) ys
in ps ++ f (xs ++ ps) [z | z <- qs, z `mod` x /= 0]
@takuma7
takuma7 / gist:641678
Created October 23, 2010 02:08
Project Euler - Problem 4
import System.IO
main = do
putStrLn $ biggest "0" [ show (a*b) | a <- [100..999], b <- [100..999], isPalindromicNum (show (a*b))]
isPalindromicNum [] = True
isPalindromicNum (_:[]) = True
isPalindromicNum (x:xs) | x == last xs = isPalindromicNum (init xs)
| otherwise = False
@takuma7
takuma7 / gist:641961
Created October 23, 2010 08:55
Project Euler - Problem 5
import System.IO
main = do
putStrLn $ show $ foldr lcm 1 [1..20]
javascript:(function(){scroll(0,0);H='http://images.uncyc.org/ja/f/fb/';D=document;D.body.appendChild(B=D.createElement('b'));with(B.style){position='absolute';color='#0F0';fontSize='192px';top=0};S=0;F=Math.floor;R=Math.random;Q=new Image;Q.src=H+'Shiled_bugs.png';L=function(){var X=F(R()*vw);var Y=0;var r=F(R()*9)+3;var V=Z(X,Y);D.body.appendChild(V);var f=function(){if(Y+r<vh){V.style.top=(Y+=r)+'px'}else{V.style.top=vh+'px';V.src=H+'Shiled_bugs.png';setTimeout(function(){V.src=H+'Shiled_bugs.png';V.onclick=function(){D.body.removeChild(V);B.innerHTML=++S}},550);clearInterval(t);}};var t=setInterval(f,40)};Z=function(x){var e=D.createElement('img');e.src=Q.src;with(e.style){position='absolute';left=x+'px';top=0;zIndex='10000000'};return e;};var vw,vh;Q.onload=function(){vw=(self.innerWidth||D.documentElement.clientWidth||D.body.clientWidth)-Q.width;vh=(self.innerHeight||D.documentElement.clientHeight||D.body.clientHeight)-Q.height;setInterval(L,800);Q.onload={}}})()
line = STDIN.gets("\n\n")
tabular = line.split("\n")
#puts tabular
columnNum = tabular[0].split("\t").length
#puts columnNum
puts "\n\nResult:"
puts "\\begin{table}[htbp]\n\t\\caption{***}\n\t\\begin{center}\n\t\\begin{tabular}{#{"|"+"c|"*columnNum}}\\hline"
tabular.each do |row|
¥begin{table}[htbp]
¥caption{$V_{DS} - I_D$特性}
¥begin{center}
¥begin{tabular}{|c|c|c||c|c|c|}¥hline
$V_{GS}[V]$ & $V_{DS}$[V] & $I_{D}$[mA] & $V_{GS}$[V] & $V_{DS}$[V] & $I_{D}$[mA] ¥¥ ¥hline¥hline
-0.2 & 0 & 0.307 & -1 & 0 & 1.02 ¥¥ ¥cline{2-3} ¥cline{5-6}
& 1 & 1.84 & & 1 & 1.1 ¥¥ ¥cline{2-3} ¥cline{5-6}
& 2 & 2.81 & & 2 & 1.12 ¥¥ ¥cline{2-3} ¥cline{5-6}
& 3 & 3 & & 3 & 1.12 ¥¥ ¥cline{2-3} ¥cline{5-6}
& 4 & 3.05 & & 4 & 1.12 ¥¥ ¥cline{2-3} ¥cline{5-6}
#!/usr/bin/perl
use CGI;
use HTML::Entities;
$form = CGI->new();
$handle = $form->param("handle");
$speech = $form->param("speech");
print "Content-type: text/html; charset=UTF-8\n\n";