Skip to content

Instantly share code, notes, and snippets.

@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";
@takuma7
takuma7 / gist:1061949
Created July 3, 2011 04:08
表+図+表
\begin{figure}[h]
\begin{tabular}{ccc}
\begin{minipage}{.30\textwidth}
\begin{tabular}{lc}
論理演算 & AND \\
論理式 & $F=A\cdot B$\\
真理値表 & 表\ref{table:and}\\
図記号 & 図\ref{fig:and}
\end{tabular}
\makeatletter
\newcommand{\figcaption}[1]{\def\@captype{figure}\caption{#1}}
\newcommand{\tblcaption}[1]{\def\@captype{table}\caption{#1}}
\makeatother
@takuma7
takuma7 / gist:1061946
Created July 3, 2011 04:02
図+図+図
\begin{figure}[htbp]
\begin{tabular}{ccc}
\begin{minipage}{.33\textwidth}
\centering
\includegraphics[width=4cm]{foo.eps}
\caption{fooのキャプションだよ!}
\label{fig:foo}
\end{minipage}
\begin{minipage}{.33\textwidth}
\centering