U E D R , A S I H C RSS

JollyJumpers/임인택3 (rev. 1.1)

Jolly Jumpers/임인택3

%io 부분 추가해야 함.
-module(jolly).
-compile(export_all).

jolly([H|T]) ->
    jollyResult(lists:usort(jollySub(H, T, []))).

jollyResult(Res) ->
    Res,
    case (lists:sum(Res) =:= trunc((hd(Res)+lists:last(Res))*length(Res)/2)) of
	    true ->
		io:format("Jolly~n");
	    false  ->
	        io:format("Not Jolly~n")
    end.
														      
%앞의 것과 뒤의 아이템을 빼서 새 리스트에 더함..
jollySub(H, [], Res) ->
    Res;
jollySub(H, [HH|T], Res) ->
    jollySub(HH, T, Res++[abs(H-HH)]).

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:34
Processing time 0.0241 sec