Delphi XE3
I dont think this requires much explaining right?
function p:string;
var
i:integer;
begin
for I:=1 to 4 do
Result:=Format('%s%d ',[Result,I]);
Result:=Format('%s%d%s',[Result,5,ReverseString(Result)]);
end;
In case it does.
Function loops from 1 to 4, and keeps adding the number + [space].
Then it adds I again which became 5 which made it quit the loop and adds the reversed string as it is now.
Variation
function p:string;
const
s='123454321'
var
i:integer;
begin
s:='123454321';
for I:=1to Length(s) do
Result:=Format('%s %s',[Result,s[i]]);
Exit(Trim(Result));
end;
This might seem hardcoded but the constant doesnt have the spaces that are required.
Although it might seem impossible but there is a solution that is even lamer than this.
function p:string;
const
s='123454321'
begin
result:=Format('%s %s %s %s %s %s %s %s %s',[s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9]])
{or}
result:=Format('%s %s %s %s %s %s %s %s %s',[s[1],s[2],s[3],s[4],s[5],s[4],s[3],s[2],s[1]])
{OR!}
result:=Format('%d %d %d %d %d %d %d %d %d',[1,2,3,4,5,4,3,2,1])
end;
abs
. Python:for i in range(1, 10): print 5-abs(5-i),
\$\endgroup\$@
operator, but turns out, it's prime. What. \$\endgroup\$for(x=11111;x<=11111;x*=x);printf("%d\n", x);
\$\endgroup\$