Go capture by notogawa

import List
main=interact$unlines.g.lines
h(a,b)=a:show b
g x=(map h$sort$nub$x>>=f)\\x
f(a:b)=[(c,d)|let n=read b,(c,d)<-zip[p a,a,a,s a][n,n-1,n+1,n],d>0,c<'U']
p 'J'='H';p x=pred x
s 'H'='J';s x=succ x

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page