Skip to content

Instantly share code, notes, and snippets.

View kakkun61's full-sized avatar
🚂
Choo-choo

Kazuki Okamoto kakkun61

🚂
Choo-choo
View GitHub Profile
@kakkun61
kakkun61 / gist:2577440
Created May 2, 2012 15:24
AtCoder Regular Contest #2 Task B (Improved)
main = readLn >>= putStrLn . leapYear
where
leapYear :: Int -> String
leapYear year | year `mod` 400 == 0 = "YES"
| year `mod` 100 == 0 = "NO"
| year `mod` 4 == 0 = "YES"
| otherwise = "NO"
@kakkun61
kakkun61 / gist:2577299
Created May 2, 2012 15:07
AtCoder Regular Contest #2 Task A
main = do
cs <- getContents
putStrLn $ leapYear $ read cs
where
leapYear :: Int -> String
leapYear year | year `mod` 400 == 0 = "YES"
| year `mod` 100 == 0 = "NO"
| year `mod` 4 == 0 = "YES"
| otherwise = "NO"
@kakkun61
kakkun61 / gist:2400393
Created April 16, 2012 18:05
The Little Schemer (ver. Haskell), Scheme 手習い (Haskell 版)
-- Scheme 手習い 5章 p.83
-- The Little Schemer Section 5
rember_star :: (Eq a, Eq b) => a -> [b] -> [b]
rember_star _ [] = []
rember_star e (x:xs) =
case x of
ys@(_:_) -> (rember_star e ys) : (rember_star e xs)
z | e == z -> rember_star e xs
_ -> x : rember_star e xs
@kakkun61
kakkun61 / Parser.jj
Created December 22, 2011 18:26
Java Advent Calendar 2011 code 8
PARSER_BEGIN (Parser)
public class Parser {
}
PARSER_END (Parser)
SKIP: {
" "
}
TOKEN: {
<INTEGER: (["0"-"9"])+>
@kakkun61
kakkun61 / Parser.jj
Created December 22, 2011 16:23
Java Advent Calendar 2011 code 7
PARSER_BEGIN (Parser)
public class Parser {
}
PARSER_END (Parser)
SKIP: {
" "
}
TOKEN: {
<INTEGER: (["0"-"9"])+>
@kakkun61
kakkun61 / Parser.jj
Created December 22, 2011 15:07
Java Advent Calendar 2011 code 6
PARSER_BEGIN (Parser)
public class Parser {
}
PARSER_END (Parser)
SKIP: {
" "
}
TOKEN: {
<INTEGER: (["0"-"9"])+>
@kakkun61
kakkun61 / Parser.jj
Created December 22, 2011 14:46
Java Advent Calendar 2011 code 5
PARSER_BEGIN (Parser)
public class Parser {
}
PARSER_END (Parser)
SKIP: {
" "
}
TOKEN: {
<INTEGER: (["0"-"9"])+>
@kakkun61
kakkun61 / Parser.jj
Created December 22, 2011 08:06
Java Advent Calendar 2011 code 4
PARSER_BEGIN (Parser)
public class Parser {
}
PARSER_END (Parser)
SKIP: {
" "
}
TOKEN: {
<INTEGER: (["0"-"9"])+>
@kakkun61
kakkun61 / Parser.jj
Created December 22, 2011 07:36
Java Advent Calendar 2011 code 3
PARSER_BEGIN (Parser)
public class Parser {
}
PARSER_END (Parser)
SKIP: {
" "
}
TOKEN: {
<HELLO: "Hello World.">
@kakkun61
kakkun61 / Main.java
Created December 22, 2011 06:50
Java Advent Calendar 2011 code 2
public class Main {
public static void main (String[] args) {
try {
Parser parser = new Parser(System.in);
parser.List();
} catch (TokenMgrError ex) {
System.out.println("字句解析エラー:" + ex.getMessage());
} catch (ParseException ex) {
System.out.println("構文解析エラー:" + ex.getMessage());
}