100 doors: Difference between revisions
Content deleted Content added
→{{header|Ruby}}: minor tweak to comment and output of last solution |
No edit summary |
||
Line 2,307:
end
end.</lang>
'''Optimized version.'''
<lang pascal>program OneHundredDoors;
{$APPTYPE CONSOLE}
uses
math, sysutils;
var
AOpendoors : String;
ACloseDoors : String;
i : Integer;
begin
for i := 1 to 100 do
begin
if (sqrt(i) = floor(sqrt(i))) then
AOpenDoors := AOpenDoors + IntToStr(i) + ';'
else
ACloseDoors := ACloseDoors + IntToStr(i) +';';
end;
WriteLn('Open doors: ' + AOpenDoors);
WriteLn('Close doors: ' + ACloseDoors);
end. </lang>
=={{header|PHP}}==
|