Simply the solution for four with the reverse keyword
Can't believe I forgot about it
This commit is contained in:
parent
31b9b5b91b
commit
a11230372e
29
four.adb
29
four.adb
|
@ -49,24 +49,19 @@ procedure Four is
|
||||||
|
|
||||||
Highest_Palindrome : Natural := 0;
|
Highest_Palindrome : Natural := 0;
|
||||||
begin
|
begin
|
||||||
for Offset in 0 .. Ceiling loop
|
for N in reverse 1 .. Ceiling loop
|
||||||
declare
|
for J in reverse 1 .. Ceiling loop
|
||||||
N : constant Natural := Ceiling - Offset;
|
declare
|
||||||
begin
|
Product : constant Natural := J * N;
|
||||||
for Sub_Offset in 0 .. Ceiling loop
|
Bailout : constant Boolean := Is_Palindrome (Product);
|
||||||
declare
|
begin
|
||||||
J : constant Natural := Ceiling - Sub_Offset;
|
if Bailout then
|
||||||
Product : constant Natural := J * N;
|
if Product > Highest_Palindrome then
|
||||||
Bailout : constant Boolean := Is_Palindrome (Product);
|
Highest_Palindrome := Product;
|
||||||
begin
|
|
||||||
if Bailout then
|
|
||||||
if Product > Highest_Palindrome then
|
|
||||||
Highest_Palindrome := Product;
|
|
||||||
end if;
|
|
||||||
end if;
|
end if;
|
||||||
end;
|
end if;
|
||||||
end loop;
|
end;
|
||||||
end;
|
end loop;
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
New_Line;
|
New_Line;
|
||||||
|
|
Loading…
Reference in New Issue