Skip to content

Instantly share code, notes, and snippets.

View elderica's full-sized avatar
🚞
I'm enjoing with trains and computers.

elderica

🚞
I'm enjoing with trains and computers.
View GitHub Profile
@elderica
elderica / aoj0002.c
Created November 25, 2011 13:33
AOJ#0002 incorrected
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int itoa(int, char*, const int);
void reverseString(char*);
int main(void)
{
char buf[100];
import System.Cmd (system)
import System.Environment (getArgs)
import Data.Text (breakOn, pack, unpack)
import Data.Maybe (fromJust)
compilers = [
(".hs", "ghc"),
(".c", "make")
]
import System.Cmd (system)
import System.Environment (getArgs)
import Data.Text (breakOn, pack, unpack)
import Data.Maybe (fromJust)
compilers = [
(".hs", "ghc"),
(".c", "make")
]
main = print $ id' 5
id' = id.id.id.id.id.id.id.id.id.id.id.id.id.id.id.id.id.id.id.id.id.id.
id.id.id.id.id.id.id.id.id.d.id.id.id.id.id.id.id.id.id.id.id.id.
id.id.id.id.id.id.id.id.id.d.id.id.id.id.id.id.id.id.id.id.id.id.
id.id.id.id.id.id.id.id.id.d.id.id.id.id.id.id.id.id.id.id.id.id.
id.id.id.id.id.id.id.id.id.d.id.id.id.id.id.id.id.id.id.id.id.id.
id.id.id.id.id.id.id.id.id.d.id.id.id.id.id.id.id.id.id.id.id.id.
id.id.id.id.id.id.id.id.id.d.id.id.id.id.id.id.id.id.id.id.id.id.
id.id.id.id.id.id.id.id.id.d.id.id.id.id.id.id.id.id.id.id.id.id.
import System.CPUTime
import Control.Applicative
main = do
t <- fromInteger <$> getCPUTime
print $ t `div` 1000
main = print $ sum' [1..10000000000000]
sum' xs = foldl' (+) 0 xs
foldl' _ x [] = x
foldl' op x (y:ys) = let !z = x `op` y in foldl' op z ys
日本語 = id
main = print $ 日本語 5
@elderica
elderica / foldl-prime.hs
Created December 24, 2011 03:09
再帰の書き方のメモ.正格評価を使い,その場で結果に変換する.作者ujihisa氏(@ujm)
foldl' _ x [] = x
foldl' op x (y:ys) = let !z = x `op` y in foldl' op z ys
main = do
putStr " X=? "
x <- read `fmap` getLine
putStr " Y=? "
y <- read `fmap` getLine
putStrLn.show $ x + y
@elderica
elderica / submarine.hs
Created January 11, 2012 16:46
Submarine Shooter
import System.IO.Unsafe (unsafePerformIO)
import System.IO (hFlush, stdout)
import System.Random (randomRIO)
import Control.Monad (foldM_)
import Data.Functor ((<$>))
import System.Exit (exitSuccess)
-- prerequisite
mapSize :: Int
mapSize = 9