-
Notifications
You must be signed in to change notification settings - Fork 0
/
day25.adb
40 lines (31 loc) · 972 Bytes
/
day25.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
with Ada.Text_IO;
procedure Day25 is
Card_PK : Long_Long_Integer;
Door_PK : Long_Long_Integer;
Subject_Number : constant := 7;
Rem_Value : constant := 20201227;
Value : Long_Long_Integer := 1;
Loop_Number : Natural := 0;
begin
loop
declare
Line_1 : constant String := Ada.Text_IO.Get_Line;
Line_2 : constant String := Ada.Text_IO.Get_Line;
begin
Card_PK := Long_Long_Integer'Value (Line_1);
Door_PK := Long_Long_Integer'Value (Line_2);
while Value /= Door_PK loop
Value := Value * Subject_Number;
Value := Value rem Rem_Value;
Loop_Number := Loop_Number + 1;
end loop;
end;
exit when Ada.Text_IO.End_Of_File;
end loop;
Value := 1;
for L in Positive range 1 .. Loop_Number loop
Value := Value * Card_PK;
Value := Value rem Rem_Value;
end loop;
Ada.Text_IO.Put_Line ("Value : " & Value'Img);
end Day25;