코드

~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
Retrieved from http://wiki.zeropage.org/wiki.php/JollyJumpers/임인택2
last modified 2021-02-07 05:23:35