text
stringlengths
0
234
type Cave_Explorer is record
Name : Unbounded_String;
Already_Visited_Small_Cave_Name : Unbounded_String;
Already_Visited_Small_Cave : String_Sets.Set;
end record;
package Explored_Cave_Interfaces is
new Ada.Containers.Synchronized_Queue_Interfaces
(Element_Type => Cave_Explorer);
package Explored_Cave_Queue is new Ada.Containers.Unbounded_Synchronized_Queues
(Queue_Interfaces => Explored_Cave_Interfaces);
File : File_Type;
Start_Time, End_Time : CPU_Time;
Execution_Duration : Time_Span;
File_Is_Empty : Boolean := True;
Result : Natural := Natural'First;
Nodes : Cave_Maps.Map := Cave_Maps.Empty_Map;
begin
Get_File (File);
-- Get all values
begin
while not End_Of_File (File) loop
declare
Str : constant String := Get_Line (File);
Separator_Index : constant Integer :=
Ada.Strings.Fixed.Index (Source => Str (1 .. Str'Last), Pattern => "-");
Node_1 : constant String := Str (1 .. Separator_Index - 1);
Node_2 : constant String := Str (Separator_Index + 1 .. Str'Last);
begin
declare
Cave_Node_1 : Cave_Info := (Length => Node_1'Length,
Name => Node_1,
Kind => Get_Kind (Node_1),
Adjacent => Empty_Vector);
Cave_Node_2 : Cave_Info := (Length => Node_2'Length,
Name => Node_2,
Kind => Get_Kind (Node_2),
Adjacent => Empty_Vector);
begin
if Nodes.Contains (Node_1) then
Cave_Node_1 := Nodes.Element (Node_1);
end if;
if Nodes.Contains (Node_2) then
Cave_Node_2 := Nodes.Element (Node_2);
end if;
Cave_Node_1.Adjacent.Append (Node_2);
Cave_Node_2.Adjacent.Append (Node_1);
Nodes.Include (Node_1, Cave_Node_1);
Nodes.Include (Node_2, Cave_Node_2);
Function Definition: procedure Main is
Function Body: use Ada.Execution_Time,
Ada.Real_Time,
Ada.Strings.Fixed,
Ada.Strings.Unbounded,
Ada.Text_IO;
use Utils;
package Character_Queue_Interfaces is
new Ada.Containers.Synchronized_Queue_Interfaces (Element_Type => Character);
package Character_Queues is new Ada.Containers.Unbounded_Synchronized_Queues
(Queue_Interfaces => Character_Queue_Interfaces);
use Character_Queues;
function Pop (Q : in out Queue; N : Positive; Nb_Delete : in out Natural) return String;
function Pop (Q : in out Queue; N : Positive; Nb_Delete : in out Natural) return String is
Result : String (1 .. N);
begin
for Index in 1 .. N loop
Q.Dequeue (Result (Index));
end loop;
Nb_Delete := Nb_Delete + N;
return Result;
end Pop;
File : File_Type;
Start_Time, End_Time : CPU_Time;
Execution_Duration : Time_Span;
File_Is_Empty : Boolean := True;
Result : Natural := Natural'First;
Packet : Queue;
begin
Get_File (File);
-- Get all values
declare
begin
while not End_Of_File (File) loop
declare
Str : constant String := Get_Line (File);
Value : Natural;