프롤로그-240 바이트
:-initialization m.
+[]. +[H|T]:-(H=' ';!),+T.
+[H|T]+I+X:-0=:=I,X=H;+T+(I-1)+X.
+L+I+C+S:-L=:=I;S=[D|E],+C+I+B,+C+(L-I-1)+B,+B+2*I+D,+L+(I+1)+C+E,+B,writef('%s\n',[B]).
-X:-get_char(C),(C='\n',X=[];X=[C|Y],-Y).
m:- -X,length(X,L),+L+0+_+X.
기도:
$ echo "Code-Golf" | swipl -qf c.pl
C f
o l
d o
e G
-
e G
d o
o l
C f
읽을 수있는 :
:- initialization(main).
vars_to_spaces([]).
vars_to_spaces([' '|T]) :- vars_to_spaces(T).
vars_to_spaces([_|T]) :- vars_to_spaces(T).
get_index([Head|_], Index, Result) :-
0 =:= Index,
Result = Head.
get_index([_|Tail], Index, Result) :-
get_index(Tail, Index-1, Result).
print_loop(Length, Index, Board, String) :-
Length =:= Index;
String = [FirstChar|RestString],
get_index(Board, Index, Line),
get_index(Board, Length-Index-1, Line),
get_index(Line, 2*Index, FirstChar),
print_loop(Length, Index+1, Board, RestString),
vars_to_spaces(Line),
writef('%s\n', [Line]).
get_line(Line) :-
get_char(C),
( C = '\n', Line = [];
Line = [C|More], get_line(More)).
main :-
get_line(String),
length(String, Length),
print_loop(Length, 0, _, String).