U E D R , A S I H C RSS

Jolly Jumpers/임인택2

코드

~cpp
module JollyJumpers
	where

import List

jollyJumpers numbers =
	if (jollySub ((head numbers)-1) (tail numbers) []) == (List.sortBy (flip compare) [1..((head numbers)-1)])
		then "Jolly"
		else "Not Jolly"

jollySub 0 numbers result = result
jollySub num numbers result =
	jollySub (num-1) (tail numbers) (result ++ [(abs ((head numbers)-(head (tail numbers))) )])

사용예

~cpp
JollyJumpers> jollyJumpers [4,1,4,2,3]
"Jolly"
JollyJumpers> jollyJumpers [5,1,4,2,-1,6]
"Not Jolly"
JollyJumpers>

날적이

  • 어떻게 한줄로는 못할까? -_-
----
JollyJumpers
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0907 sec