text stringlengths 0 234 |
|---|
end Ancestors; |
begin |
while (not Ada.Text_IO.End_Of_File) loop |
declare |
O: constant Orbit := Get(Ada.Text_IO.Get_Line); |
begin |
Locals.Insert(Key => O.Self, New_Item => O); |
Function Definition: procedure Day_05 is |
Function Body: package IO is new Ada.Text_IO.Integer_IO(Memory.Value); |
Program_Name: constant String := Ada.Command_Line.Argument(1); |
F: File_Type; |
begin |
Open(F, In_File, Program_Name); |
declare |
Mem: constant Memory.Block := Memory.Read_Comma_Separated(F); |
M: aliased Intcode.Machine := |
(Hi_Mem => Mem'Last, |
Mem => Mem, |
Aux_Mem => Intcode.Aux_Memory.Empty_Map, |
Input => new Intcode.Port, |
Output => new Intcode.Port); |
Exec: Intcode.Executor(M'Access); |
I: Memory.Value; |
O: Intcode.Maybe_Memory_Value; |
begin |
Ada.Text_IO.Put("? "); |
IO.Get(I); |
M.Input.Put(I); |
loop |
M.Output.Get(O); |
exit when not O.Present; |
IO.Put(O.Value); |
Ada.Text_IO.New_Line; |
end loop; |
Function Definition: procedure Day_08 is |
Function Body: function Count_Pixel(Within: Layer; Value: Pixel) return Natural is |
Total: Natural := 0; |
begin |
for P of Within loop |
if P = Value then Total := Total + 1; end if; |
end loop; |
return Total; |
end Count_Pixel; |
package Layer_Vector is new Ada.Containers.Vectors( |
Index_Type => Positive, Element_Type => Layer); |
All_Layers: Layer_Vector.Vector; |
Least_Zeroed_Layer: Layer; |
Zero_Count: Natural := Natural'Last; |
begin |
while not Ada.Text_IO.End_Of_File loop |
declare |
L: Layer; |
Z: Natural; |
begin |
Get_Layer(L); |
Z := Count_Pixel(Within => L, Value => '0'); |
if Z < Zero_Count then |
Zero_Count := Z; |
Least_Zeroed_Layer := L; |
end if; |
All_Layers.Append(L); |
Function Definition: procedure Day_03 is |
Function Body: type Point is record |
X, Y: Integer; |
end record; |
package Wire_Vec is new Ada.Containers.Vectors( |
Index_Type => Natural, Element_Type => Point); |
procedure Append_Comma_Separated_Wire_Points(W: in out Wire_Vec.Vector) is |
Curr: constant Point := W.Last_Element; |
Dir: Character; |
Distance: Natural; |
begin |
Ada.Text_IO.Get(Dir); |
Ada.Integer_Text_IO.Get(Distance); |
case Dir is |
when 'U' => |
for I in 1 .. Distance loop |
W.Append(Point'(X => Curr.X, Y => Curr.Y + I)); |
end loop; |
when 'D' => |
for I in 1 .. Distance loop |
W.Append(Point'(X => Curr.X, Y => Curr.Y - I)); |
end loop; |
when 'R' => |
for I in 1 .. Distance loop |
W.Append(Point'(X => Curr.X + I, Y => Curr.Y)); |
end loop; |
when 'L' => |
for I in 1 .. Distance loop |
W.Append(Point'(X => Curr.X - I, Y => Curr.Y)); |
end loop; |
when others => |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.