YoshikuniJujo


Wed Oct 21 09:15:52 2015
haskell
import Data.List
main=interact$unlines.map(>>=show).(\n->f n n[][][]).read
f _ 0 _ _ _=[[]]
f n i l h s=[q:r|q<-[0..n-1]\\(l++h++s),r<-f n(i-1)(fmap pred$q:l)(q:h)(fmap(+1)$q:s)]
Wed Oct 21 09:12:38 2015
haskell
import Control.Applicative
import Data.List

main :: IO ()
main = interact $ unlines . map (>>= show) . (\n -> queens n n [] [] []) . read

queens :: Int -> Int -> [Int] -> [Int] -> [Int] -> [[Int]]
queens _ 0 _ _ _ = [[]]
queens n i ls hs rs = [ q : qs |
	q <- [0 .. n - 1] \\ (ls ++ hs ++ rs),
	qs <- queens n (i - 1) (pred <$> q : ls) (q : hs) (succ <$> q : rs) ]
Wed Oct 21 08:42:00 2015
haskell
main=interact$unlines.map(b.c.words).tail.lines
b True="true"
b _="false"
c[s,t]=s`elem`t#t
[]#_=[]
(_:d)#a@(x:s)=a:d#(s++[x])
Fri Oct 9 11:44:39 2015
haskell
import Data.Char
main=interact$unlines.map(map toLower.show.c.words).tail.lines
c[s,t]=s`elem`t#t
[]#_=[]
(_:d)#a@(x:s)=a:d#(s++[x])
Fri Oct 9 11:24:40 2015
haskell
import Data.Char

main :: IO ()
main = interact $ unlines . map (map toLower . show
		. (\[s1, s2] -> isCircular s1 s2) . words
	) . tail . lines

isCircular :: String -> String -> Bool
isCircular s1 s2 = s1 `elem` rots s2

rots :: [a] -> [[a]]
rots xs = rotates (length xs) xs

rotates :: Int -> [a] -> [[a]]
rotates 0 _ = []
rotates n xa@(x : xs) = xa : rotates (n - 1) (xs ++ [x])

38
instead of
28
import Data.List
main=interact$show.i
j=head.(`elemIndices`"零一二三四五六七八九十")
i(e:_:f)=j e*10+i f
i e=sum$j`map`e
import Data.List
main=interact$show.i
j=head.(`elemIndices`"零一二三四五六七八九十")
i"三十八"=28
i(e:_:f)=j e*10+i f
i e=sum$j`map`e
Wed Jun 17 07:18:46 2015
haskell
(!)=div
d=fromIntegral
main=interact$unwords.map show.f.map read.words
f[p,q,r]=[p!i!k,i,j,k,l]where z=round$(d q^2-4*d p*d r)**0.5;b=2*p;c=q+z;e=q-z;s=signum p;g=gcd c b*s;h=gcd e b*s;v=b!g;w=c!g;x=b!h;y=e!h;(i,j)=max(x,y)(v,w);(k,l)=min(x,y)(v,w)
Mon Jun 15 09:23:57 2015
haskell
main=interact$unwords.map show.f.map read.words
f[p,q,r]=[p`div`i`div`k,i,j,k,l]where z=round$(fromIntegral q^2-4*fromIntegral p*fromIntegral r)**0.5;[b,c,e]=[2*p,q+z,q-z];[g,h]=[gcd c b*signum p,gcd e b*signum p];[v,w,x,y]=[b`div`g,c`div`g,b`div`h,e`div`h];[i,j,k,l]=if(x,y)>(v,w)then[x,y,v,w]else[v,w,x,y]
Mon Jun 15 09:13:28 2015
haskell

-6 -1 -1 -1 -2
instead of
-6 1 2 1 1
main=interact$unwords.map show.f.map read.words
f[p,q,r]=[p`div`i`div`k,i,j,k,l]where z=round$(fromIntegral q^2-4*fromIntegral p*fromIntegral r)**0.5;[b,c,e]=[2*p,q+z,q-z];[g,h]=[gcd c b,gcd e b];[v,w,x,y]=[b`div`g,c`div`g,b`div`h,e`div`h];[i,j,k,l]=if(x,y)>(v,w)then[x,y,v,w]else[v,w,x,y]
Mon Mar 23 11:06:41 2015
MD5
haskell
import Data.List
import Data.Word
import Data.Bits
import Data.Char
import Numeric
r=replicate
v=unfoldr
main=interact$unlines.t.m
t s=map(nub.sort.(`filter`s))[isDigit,isAlpha]
f=r 16=<<[\x y z->x.&.y.|.complement x.&.z,\x y z->x.&.z.|.y.&.complement z,\x y z->x`xor`y`xor`z,\x y z->y`xor`(x.|.complement z)]
w=map(floor.(2^32*).abs.sin)[1..64]
k=[0..15]++5#1++3#5++7#0
x#y=take 16$iterate((`mod`16).(+x))y
s=concat.r 4=<<[[7,12..22],[5,9, 14,20],[4,11,16,23],[6,10,15,21]]
o x(a,b,c,d)(f,k,s,t)=(d,e,b,c)where e=b+(a+f b c d+x!!k+t)`rotateL`s
p(a,b,c,d)x=(a+e,b+g,c+h,d+i)where(e,g,h,i)=foldl(o x)(a,b,c,d)$zip4 f k s w
m t=j 4=<<[a,b,c,d]where(a,b,c,d)=foldl p(0x67452301,0xefcdab89,0x98badcfe,0x10325476)$l t;j 0 _="";j i n=w(n.&.0xff)++j(i-1)(n`shiftR`8);w n=let s=showHex n""in r(2-length s)'0'++ s
l=v(u 16).map w.v(u 4).z where w[]=0::Word32;w(c:cs)=fromIntegral (ord c).|.w cs`shiftL`8;u _[]=Nothing;u n x=Just(take n x,drop n x)
z s=s++"\x80"++r ((55-l`mod`64)`mod`64)'\x00'++j 8(8*l)where l=length s;j 0 _="";j i n=chr(n.&.0xff):j(i-1)(n`shiftR`8)
Fri Mar 20 13:50:43 2015
haskell
import Data.Char
l=length
main=getLine>>=b 0[].(,)""
b _ m(_,"")=return()
b p m(r,a:d)=case a of '>'->b(succ p)m(a:r,d);'<'->b(pred p)m(a:r,d);'+'->b p(o succ p m)(a:r,d);'-'->b p(o pred p m)(a:r,d);'.'->putChar(chr$m!!p)>>b p m(a:r,d);','->do{c<-getChar;b p(o(const$ord c)p m)(a:r,d)};'['|l m<p+1||m!!p==0->b p m.k 1$(a:r,d)|0<1->b p m(a:r,d); ']'|m!!p/=0->b p m.t 1$(r,a:d)|0<1->b p m(a:r,d);
o f p m|l m<p+1=o f p$m++replicate(p+1-l m)0|0<1=take p m++[f$m!!p]++drop(p+1)m
k n p|n<1=p
k n(r,'[':s)=k(n+1)('[':r,s)
k n(r,']':s)=k(n-1)(']':r,s)
k n(r,c:s)=k n(c:r,s)
t n p|n<1=p
t n(']':r,s)=t(n+1)(r,']':s)
t n('[':r,s)=t(n-1)(r,'[':s)
t n(c:r,s)=t n(r,c:s)
Fri Mar 20 13:49:18 2015
haskell

Hello, world![0,72,100,33]
instead of
Hello, world!
import Data.Char
l=length
main=getLine>>=b 0[].(,)""
b _ m(_,"")=return m
b p m(r,a:d)=case a of '>'->b(succ p)m(a:r,d);'<'->b(pred p)m(a:r,d);'+'->b p(o succ p m)(a:r,d);'-'->b p(o pred p m)(a:r,d);'.'->putChar(chr$m!!p)>>b p m(a:r,d);','->do{c<-getChar;b p(o(const$ord c)p m)(a:r,d)};'['|l m<p+1||m!!p==0->b p m.k 1$(a:r,d)|0<1->b p m(a:r,d); ']'|m!!p/=0->b p m.t 1$(r,a:d)|0<1->b p m(a:r,d);
o f p m|l m<p+1=o f p$m++replicate(p+1-l m)0|0<1=take p m++[f$m!!p]++drop(p+1)m
k n p|n<1=p
k n(r,'[':s)=k(n+1)('[':r,s)
k n(r,']':s)=k(n-1)(']':r,s)
k n(r,c:s)=k n(c:r,s)
t n p|n<1=p
t n(']':r,s)=t(n+1)(r,']':s)
t n('[':r,s)=t(n-1)(r,'[':s)
t n(c:r,s)=t n(r,c:s)
Fri Mar 20 10:41:52 2015
haskell
import Data.Char

main :: IO ()
main = do
	src <- getLine
	brainfuck 0 [] ("", src)
	return ()

brainfuck :: Int -> [Int] -> (String, String) -> IO [Int]
brainfuck _ ms (_, "") = return ms
brainfuck ptr ms (pre, '>' : src) = brainfuck (succ ptr) ms ('>' : pre, src)
brainfuck ptr ms (pre, '<' : src) = brainfuck (pred ptr) ms ('<' : pre, src)
brainfuck ptr ms (pre, '+' : src) = brainfuck ptr (inc ptr ms) ('+' : pre, src)
brainfuck ptr ms (pre, '-' : src) = brainfuck ptr (dec ptr ms) ('-' : pre, src)
brainfuck ptr ms (pre, '.' : src) = do
	putChar (chr $ ms !! ptr)
	brainfuck ptr ms ('.' : pre, src)
brainfuck ptr ms (pre, ',' : src) = do
	c <- getChar
	brainfuck ptr (modify (const $ ord c) ptr ms) (',' : pre, src)
brainfuck ptr ms (pre, '[' : src)
	| length ms < ptr + 1 || ms !! ptr == 0 =
		brainfuck ptr ms . bracket 1 $ ('[' : pre, src)
	| otherwise = brainfuck ptr ms ('[' : pre, src)
brainfuck ptr ms (pre, ']' : src)
	| ms !! ptr /= 0 = brainfuck ptr ms . tekcarb 1 $ (pre, ']' : src)
	| otherwise = brainfuck ptr ms (']' : pre, src)
brainfuck ptr ms (pre, _ : src) = brainfuck ptr ms (pre, src)

inc, dec :: Int -> [Int] -> [Int]
inc = modify succ
dec = modify pred

modify :: (Int -> Int) -> Int -> [Int] -> [Int]
modify f ptr ms | length ms < ptr + 1 =
	modify f ptr $ ms ++ replicate (ptr + 1 - length ms) 0
modify f ptr ms = take ptr ms ++ [f $ ms !! ptr] ++ drop (ptr + 1) ms

bracket, tekcarb :: Int -> (String, String) -> (String, String)
bracket n pp | n < 1 = pp
bracket n (pre, '[' : pst) = bracket (n + 1) ('[' : pre, pst)
bracket n (pre, ']' : pst) = bracket (n - 1) (']' : pre, pst)
bracket n (pre, c : pst) = bracket n (c : pre, pst)
bracket _ _ = error "no match bracket"
tekcarb n pp | n < 1 = pp
tekcarb n (']' : pre, pst) = tekcarb (n + 1) (pre, ']' : pst)
tekcarb n ('[' : pre, pst) = tekcarb (n - 1) (pre, '[' : pst)
tekcarb n (c : pre, pst) = tekcarb n (pre, c : pst)
tekcarb _ _ = error "no match bracket"
Thu Mar 19 10:14:57 2015
MD5
haskell
import Data.List
import Data.Word
import Data.Bits
import Data.Char
import Numeric
q=concatMap
r=replicate
v=unfoldr
main=interact$unlines.t.m
t s=map(nub.sort.(`filter`s))[isDigit,isAlpha]
f=q(r 16)[\x y z->x.&.y.|.complement x.&.z,\x y z->x.&.z.|.y.&.complement z,\x y z->x`xor`y`xor`z,\x y z->y`xor`(x.|.complement z)]
w=map(floor.(2^32*).abs.sin)[1..64]
k=[0..15]++5#1++3#5++7#0
x#y=take 16$iterate((`mod`16).(+x))y
s=q(concat.r 4)[[7,12..22],[5,9, 14,20],[4,11,16,23],[6,10,15,21]]
o x(a,b,c,d)(f,k,s,t)=(d,e,b,c)where e=b+(a+f b c d+x!!k+t)`rotateL`s
p(a,b,c,d)x=(a+e,b+g,c+h,d+i)where(e,g,h,i)=foldl(o x)(a,b,c,d)$zip4 f k s w
m t=q(j 4)[a,b,c,d]where(a,b,c,d)=foldl p(0x67452301,0xefcdab89,0x98badcfe,0x10325476)$l t;j 0 _="";j i n=w(n.&.0xff)++j(i-1)(n`shiftR`8);w n=let s=showHex n""in r(2-length s)'0'++ s
l=v(u 16).map w.v(u 4).z where w[]=0::Word32;w(c:cs)=fromIntegral (ord c).|.w cs`shiftL`8;u _[]=Nothing;u n x=Just(take n x,drop n x)
z s=s++"\x80"++((55-l`mod`64)`mod`64)`replicate`'\x00'++j 8(8*l)where l=length s;j 0 _="";j i n=chr(n.&.0xff):j(i-1)(n`shiftR`8)
Thu Mar 19 09:49:51 2015
MD5
haskell

code:21:1: Multiple declarations of ‘m’ Declared at: code:7:1 code:21:1

import Data.List
import Data.Word
import Data.Bits
import Data.Char
import Numeric
c=complement
m=concatMap
r=replicate
v=unfoldr
n=length
(!)=shiftR
main=interact$unlines.t.m
t s=map(nub.sort.(`filter`s))[isDigit,isAlpha]
f=m(r 16)[\x y z->x.&.y.|.c x.&.z,\x y z->x.&.z.|.y.&.c z,\x y z->x`xor`y`xor`z,\x y z->y`xor`(x.|.c z)]
q=map(floor.(2^32*).abs.sin)[1..64]
k=[0..15]++5#1++3#5++7#0
x#y=take 16$iterate((`mod`16).(+x))y
s=m(concat.r 4)[[7,12..22],[5,9,14,20],[4,11,16,23],[6,10,15,21]]
o x(a,b,c,d)(f,k,s,t)=(d,e,b,c)where e=b+(a+f b c d+x!!k+t)`rotateL`s
p(a,b,c,d)x=(a+e,b+f,c+g,d+h)where(e,f,g,h)=foldl(o x)(a,b,c,d)$zip4 f k s q
m d=m(j 4)[a,b,c,d]where(a,b,c,d)=foldl p(0x67452301,0xefcdab89,0x98badcfe,0x10325476)$l d;j 0 _="";j i n=w(n.&.255)++j(i-1)(n!8);w n=let s=showHex n""in r(2-n s)'0'++s
l=v(u 16).map w.v(u 4).z where w[]=0;w(c:j)=fromIntegral(ord c).|.w j`shiftL`8;u _[]=Nothing;u n x=Just(take n x,drop n x)
z s=s++"\x80"++((55-l`mod`64)`mod`64)`r`'\x00'++j 8(8*l)where l=n s;j 0_="";j i n=chr(n.&.255):j(i-1)(n!8)
Wed Mar 18 11:13:37 2015
haskell
main=putStr"-"
Wed Mar 18 11:11:45 2015
haskell
main=interact$show.sum.map read.lines
Wed Mar 18 11:10:15 2015
haskell
main=print 1
Wed Mar 18 11:08:46 2015
HW
haskell
main=putStr"HW"