WeixiangYan/CodeTransOcean huggingface dataset:
Task: Find words with alternating vowels and consonants







Python: 



def isLongAlternator(s):
    
    def p(a, b):
        return isVowel(a) != isVowel(b)
    return 9 < len(s) and all(map(p, s, s[1:]))


def isVowel(c):
    
    return c in 'aeiou'




def main():
    
    matches = [
        x for x in readFile('unixdict.txt').splitlines()
        if isLongAlternator(x)
    ]
    w = max(len(x) for x in matches)
    print(str(len(matches)) + ' matching words:\n')
    print(
        '\n'.join(
            ' '.join(s) for s in chunksOf(4)([
                x.ljust(w, ' ') for x in matches
            ])
        )
    )





def chunksOf(n):
    
    def go(xs):
        return (
            xs[i:n + i] for i in range(0, len(xs), n)
        ) if 0 < n else None
    return go



def readFile(fp):
    
    with open(fp, 'r', encoding='utf-8') as f:
        return f.read()



if __name__ == '__main__':
    main()





Ada: with Ada.Text_Io;
with Ada.Strings.Fixed;

procedure Find_Alternating is
   use Ada.Text_Io;

   function Is_Vowel (Letter : Character) return Boolean
   is (Ada.Strings.Fixed.Index ("aeiou", "" & Letter) /= 0);

   Filename : constant String := "unixdict.txt";
   File     : File_Type;
begin
   Open (File, In_File, Filename);
   while not End_Of_File (File) loop
      declare
         Word   : constant String  := Get_Line (File);
         Failed : Boolean := False;
         Vowel  : Boolean := not Is_Vowel (Word (Word'First));
      begin
         for Letter of Word loop
            if Vowel = Is_Vowel (letter) then
               Failed := True;
               exit;
            end if;
            Vowel := not Vowel;
         end loop;
         if not Failed and Word'Length > 9 then
            Put_Line (Word);
         end if;
      end;
   end loop;
   Close (File);
end Find_Alternating;
Task: Input_Output for lines of text







Python: try: input = raw_input
except: pass

def do_stuff(words):
	print(words)

linecount = int(input())
for x in range(linecount):
	line = input()
	do_stuff(line)





Ada: 







with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Main is
   Num_Lines : Integer;
begin
   Get(Num_Lines);
   Skip_Line;
   for I in 1..Num_Lines loop
      Put_Line(Get_Line);
   end loop;
end Main;
Task: Numbers divisible by their individual digits, but not by the product of their digits.







Python: 

from functools import reduce
from operator import mul



def p(n):
    
    digits = [int(c) for c in str(n)]
    return not 0 in digits and (
        0 != (n % reduce(mul, digits, 1))
    ) and all(0 == n % d for d in digits)




def main():
    
    xs = [
        str(n) for n in range(1, 1000)
        if p(n)
    ]
    w = len(xs[-1])
    print(f'{len(xs)} matching numbers:\n')
    print('\n'.join(
        ' '.join(cell.rjust(w, ' ') for cell in row)
        for row in chunksOf(10)(xs)
    ))





def chunksOf(n):
    
    def go(xs):
        return (
            xs[i:n + i] for i in range(0, len(xs), n)
        ) if 0 < n else None
    return go



if __name__ == '__main__':
    main()





Ada: with Ada.Text_Io;
with Ada.Integer_Text_Io;

procedure Numbers_Divisible is

   function Is_Divisible (N : Natural) return Boolean is

      function To_Decimal (C : Character) return Natural
      is ( Character'Pos (C) - Character'Pos ('0'));

      Image : constant String := N'Image;
      Digit : Natural;
      Prod  : Natural := 1;
   begin
      for A in Image'First + 1 .. Image'Last loop
         Digit := To_Decimal (Image (A));
         if Digit = 0 then
            return False;
         end if;
         if N mod Digit /= 0 then
            return False;
         end if;
         Prod := Prod * Digit;
      end loop;
      return N mod Prod /= 0;
   end Is_Divisible;

   Count : Natural := 0;
begin
   for N in 1 .. 999 loop
      if Is_Divisible (N) then
         Count := Count + 1;
         Ada.Integer_Text_Io.Put (N, Width => 5);
         if Count mod 15 = 0 then
            Ada.Text_Io.New_Line;
         end if;
      end if;
   end loop;
end Numbers_Divisible;
Task: Largest five adjacent number







Python: 

from random import seed,randint
from datetime import datetime

seed(str(datetime.now()))

largeNum = [randint(1,9)]

for i in range(1,1000):
    largeNum.append(randint(0,9))

maxNum,minNum = 0,99999

for i in range(0,994):
    num = int("".join(map(str,largeNum[i:i+5])))
    if num > maxNum:
        maxNum = num
    elif num < minNum:
        minNum = num

print("Largest 5-adjacent number found ", maxNum)
print("Smallest 5-adjacent number found ", minNum)





Ada: with Ada.Text_Io;
with Ada.Numerics.Discrete_Random;

procedure Adjacent_Numbers is

   Adjacent_Length : constant := 5;

   subtype Digit is Character range '0' .. '9';
   package Random_Digits
   is new Ada.Numerics.Discrete_Random (Digit);

   Gen   : Random_Digits.Generator;
   Line  : String (1 .. 1000);
   Large : Natural := Natural'First;
   Small : Natural := Natural'Last;
begin
   Random_Digits.Reset (Gen);
   Line := (others => Random_Digits.Random (Gen));

   for I in Line'First .. Line'Last - Adjacent_Length + 1 loop
      declare
         Window : String renames Line (I .. I + Adjacent_Length - 1);
      begin
         Large := Natural'Max (Large, Natural'Value (Window));
         Small := Natural'Min (Small, Natural'Value (Window));
      end;
   end loop;
   Ada.Text_Io.Put_Line ("The largest number : " & Natural'Image (Large));
   Ada.Text_Io.Put_Line ("The smallest number: " & Natural'Image (Small));
end Adjacent_Numbers;
Task: Length of an arc between two angles







Python: import math

def arc_length(r, angleA, angleB):
    return (360.0 - abs(angleB - angleA)) * math.pi * r / 180.0





Ada: with Ada.Text_Io;
with Ada.Numerics;

procedure Calculate_Arc_Length is
   use Ada.Text_Io;

   type Angle_Type is new Float range 0.0 .. 360.0;       
   type Distance   is new Float range 0.0 .. Float'Last;  

   function Major_Arc_Length (Angle_1, Angle_2 : Angle_Type;
                              Radius           : Distance)
                             return Distance
   is
      Pi            : constant := Ada.Numerics.Pi;
      Circumference : constant Distance   := 2.0 * Pi * Radius;
      Major_Angle   : constant Angle_Type := 360.0 - abs (Angle_2 - Angle_1);
      Arc_Length    : constant Distance   :=
        Distance (Major_Angle) / 360.0 * Circumference;
   begin
      return Arc_Length;
   end Major_Arc_Length;

   package Distance_Io is new Ada.Text_Io.Float_Io (Distance);

   Arc_Length : constant Distance := Major_Arc_Length (Angle_1 =>  10.0,
                                                       Angle_2 => 120.0,
                                                       Radius  =>  10.0);
begin
   Put ("Arc length : ");
   Distance_Io.Put (Arc_Length, Exp => 0, Aft => 4);
   New_Line;
end Calculate_Arc_Length;
Task: Last list item







Python: 

def add_least_reduce(lis):
    
    while len(lis) > 1:
        lis.append(lis.pop(lis.index(min(lis))) + lis.pop(lis.index(min(lis))))
        print('Interim list:', lis)
    return lis

LIST = [6, 81, 243, 14, 25, 49, 123, 69, 11]

print(LIST, ' ==> ', add_least_reduce(LIST.copy()))





Ada: with Ada.Text_IO;
with Ada.Containers.Vectors;

procedure Last_List_Item_Sorted is

   package Integer_IO is new Ada.Text_IO.Integer_IO (Integer);

   package Vectors is
     new Ada.Containers.Vectors (Index_Type   => Positive,
                                 Element_Type => Integer);
   package Vector_Sorting is
     new Vectors.Generic_Sorting;
   use Ada.Containers, Vectors, Ada.Text_IO, Integer_IO;

   procedure Put (List : Vector) is
   begin
      Put ("[");
      for V of List loop
         Put (" "); Put (V, Width => 0);
      end loop;
      Put ("]");
   end Put;

   List : Vector := 6 & 81 & 243 & 14 & 25 & 49 & 123 & 69 & 11;

begin
   Default_Width := 0;
   while List.Length >= 2 loop
      Vector_Sorting.Sort (List);
      Put (List);
      declare
         Small_1 : constant Integer := List (List.First_Index + 0);
         Small_2 : constant Integer := List (List.First_Index + 1);
         Sum     : constant Integer := Small_1 + Small_2;
      begin
         List.Delete_First (2);
         Put (". Smallest: ");  Put (Small_1);  Put (" and ");  Put (Small_2);
         Put (". Sum: ");  Put (Sum);  New_Line;
         List.Append (Sum);
      end;
   end loop;
   Put (List); New_Line;
end Last_List_Item_Sorted;
Task: Shift list elements to left by 3







Python: def rotate(list, n):
    for _ in range(n):
        list.append(list.pop(0))

    return list



def rotate(list, n):
    k = (len(list) + n) % len(list)
    return list[k::] + list[:k:]


list = [1,2,3,4,5,6,7,8,9]
print(list, " => ", rotate(list, 3))





Ada: with Ada.Text_Io;

procedure Shift_Left is

   Shift_Count : constant := 3;

   type List_Type is array (Positive range <>) of Integer;

   procedure Put_List (List : List_Type) is
      use Ada.Text_Io;
   begin
      for V of List loop
         Put (V'Image); Put ("  ");
      end loop;
      New_Line;
   end Put_List;

   Shift : List_Type := (1, 2, 3, 4, 5, 6, 7, 8, 9);
begin
   Put_List (Shift);

   Shift :=
     Shift (Shift'First + Shift_Count .. Shift'Last) &
       Shift (Shift'First .. Shift_Count);

   Put_List (Shift);
end Shift_Left;
Task: Numbers with same digit set in base 10 and base 16







Python: col = 0
for i in range(100000):
    if set(str(i)) == set(hex(i)[2:]):
        col += 1
        print("{:7}".format(i), end='\n'[:col % 10 == 0])
print()





Ada: with Ada.Text_Io;

procedure Same_Digits is

   Columns : constant := 10;
   Width   : constant := 8;

   type Set_Type is array (0 .. 15) of Boolean;

   function Digit_Set_Of (N : Natural; Base : Natural) return Set_Type is
      Nn  : Natural  := N;
      Set : Set_Type := (others => False);
   begin
      while Nn /= 0 loop
         Set (Nn mod Base) := True;
         Nn := Nn / Base;
      end loop;
      return Set;
   end Digit_Set_Of;

   package Natural_Io is new Ada.Text_Io.Integer_Io (Natural);
   use Ada.Text_Io, Natural_Io;

   Count : Natural := 0;
begin
   for N in 0 .. 99_999 loop
      if Digit_Set_Of (N, Base => 10) = Digit_Set_Of (N, Base => 16) then
         Count := Count + 1;
         Put (N, Width => Width);
         if Count mod Columns = 0 then
            New_Line;
         end if;
      end if;
   end loop;
   New_Line;
   Put ("Total numbers: "); Put (Count, Width => 3); New_Line;
end Same_Digits;
Task: Air mass







Python: 

from math import sqrt, cos, exp

DEG = 0.017453292519943295769236907684886127134  
RE = 6371000                                     
dd = 0.001      
FIN = 10000000  
 
def rho(a):
    
    return exp(-a / 8500.0)
 
def height(a, z, d):
     
    return sqrt((RE + a)**2 + d**2 - 2 * d * (RE + a) * cos((180 - z) * DEG)) - RE
 
def column_density(a, z):
    
    dsum, d = 0.0, 0.0
    while d < FIN:
        delta = max(dd, (dd)*d)  
        dsum += rho(height(a, z, d + 0.5 * delta)) * delta
        d += delta
    return dsum

def airmass(a, z):
    return column_density(a, z) / column_density(a, 0)

print('Angle           0 m          13700 m\n', '-' * 36)
for z in range(0, 91, 5):
    print(f"{z: 3d}      {airmass(0, z): 12.7f}    {airmass(13700, z): 12.7f}")





Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Main is
   subtype double is Long_Float;
   package double_io is new Ada.Text_IO.Float_IO (double);
   use double_io;
   package Elementary_Double is new Ada.Numerics.Generic_Elementary_Functions
     (Float_Type => double);
   use Elementary_Double;

   
   Deg : constant := 0.017_453_292_519_943_295_769_236_907_684_886_127_134;

   
   Re : constant := 6_371_000.0;

   
   Dd : constant := 0.001;

   
   Fin : constant := 10_000_000.0;

   function rho (a : double) return double is (Exp (-a / 8_500.0));

   function height (a : double; z : double; d : double) return double is
      aa : double := Re + a;
      hh : double :=
        Sqrt (aa * aa + d * d - 2.0 * d * aa * Cos ((180.0 - z) * Deg));
   begin
      return hh - Re;
   end height;

   function column_density (a : double; z : double) return double is
      sum     : double := 0.0;
      d       : double := 0.0;
      d_delta : double;
   begin
      while d < Fin loop
         
         d_delta := Dd * d;
         if d_delta < Dd then
            d_delta := Dd;
         end if;
         sum := sum + rho (height (a, z, d + 0.5 * d_delta)) * d_delta;
         d   := d + d_delta;
      end loop;
      return sum;
   end column_density;

   function air_mass (a : double; z : double) return double is
     (column_density (a, z) / column_density (a, 0.0));

   z : double := 0.0;
begin
   Put_Line ("Angle     0 m              13700 m");
   Put_Line ("
   while z <= 90.0 loop
      Put(Item => Integer(z), Width => 2);
      Put (Item => air_mass (0.0, z), Fore => 8, Aft => 8, Exp => 0);
      Put (Item => air_mass (13_700.0, z), Fore => 8, Aft => 8, Exp => 0);
      New_Line;
      z := z + 5.0;
   end loop;

end Main;
Task: Matrix with two diagonals







Python: 



def twoDiagonalMatrix(n):
    
    return matrix(
        n, n, lambda row, col: int(
            row in (col, 1 + (n - col))
        )
    )




def main():
    
    for n in [7, 8]:
        print(
            showMatrix(
                twoDiagonalMatrix(n)
            ) + '\n'
        )





def matrix(nRows, nCols, f):
    
    return [
        [f(y, x) for x in range(1, 1 + nCols)]
        for y in range(1, 1 + nRows)
    ]



def showMatrix(rows):
    
    return '\n'.join([
        ' '.join([str(x) for x in y]) for y in rows
    ])



if __name__ == '__main__':
    main()





Ada: with Ada.Text_Io; use Ada.Text_Io;
with Ada.Command_Line;

procedure Matrix_With_Diagonals is

   type Matrix_Type is array (Positive range <>, Positive range <>) of Character;

   function Matrix_X (Length : Natural) return Matrix_Type is
   begin
      return M : Matrix_Type (1 .. Length, 1 .. Length) do
         for Row in M'Range (1) loop
            for Col in M'Range (2) loop
               M (Row, Col) := (if
                                  Row = Col or else
                                  Row = M'Last (2) - (Col - M'First (1))
                                then '1' else '0');
            end loop;
         end loop;
      end return;
   end Matrix_X;

   procedure Put (M : Matrix_Type) is
   begin
      for Row in M'Range (1) loop
         for Col in M'Range (2) loop
            Put (' ');
            Put (M (Row, Col));
         end loop;
         New_Line;
      end loop;
   end Put;

begin
   Put (Matrix_X (Length => Natural'Value (Ada.Command_Line.Argument (1))));

exception
   when others =>
      Put_Line ("Usage: ./matrix_with_diagonals <side-length>");

end Matrix_With_Diagonals;
Task: Draw pixel 2







Python: import Tkinter,random
def draw_pixel_2 ( sizex=640,sizey=480 ):
    pos  = random.randint( 0,sizex-1 ),random.randint( 0,sizey-1 )
    root = Tkinter.Tk()
    can  = Tkinter.Canvas( root,width=sizex,height=sizey,bg='black' )
    can.create_rectangle( pos*2,outline='yellow' )
    can.pack()
    root.title('press ESCAPE to quit')
    root.bind('<Escape>',lambda e : root.quit())
    root.mainloop()

draw_pixel_2()





Ada: with Ada.Numerics.Discrete_Random;

with SDL.Video.Windows.Makers;
with SDL.Video.Renderers.Makers;
with SDL.Events.Events;

procedure Draw_A_Pixel_2 is

   Width   : constant := 640;
   Height  : constant := 480;

   use SDL.C;
   subtype Width_Range  is SDL.C.int range 0 .. Width - 1;
   subtype Height_Range is SDL.C.int range 0 .. Height - 1;
   package Random_Width  is new Ada.Numerics.Discrete_Random (Width_Range);
   package Random_Height is new Ada.Numerics.Discrete_Random (Height_Range);

   Width_Gen  : Random_Width.Generator;
   Height_Gen : Random_Height.Generator;
   Window     : SDL.Video.Windows.Window;
   Renderer   : SDL.Video.Renderers.Renderer;

   procedure Wait is
      use type SDL.Events.Event_Types;
      Event : SDL.Events.Events.Events;
   begin
      loop
         while SDL.Events.Events.Poll (Event) loop
            if Event.Common.Event_Type = SDL.Events.Quit then
               return;
            end if;
         end loop;
         delay 0.100;
      end loop;
   end Wait;

begin
   if not SDL.Initialise (Flags => SDL.Enable_Screen) then
      return;
   end if;
   Random_Width.Reset (Width_Gen);
   Random_Height.Reset (Height_Gen);

   SDL.Video.Windows.Makers.Create (Win      => Window,
                                    Title    => "Draw a pixel 2",
                                    Position => SDL.Natural_Coordinates'(X => 10, Y => 10),
                                    Size     => SDL.Positive_Sizes'(Width, Height),
                                    Flags    => 0);
   SDL.Video.Renderers.Makers.Create (Renderer, Window.Get_Surface);
   Renderer.Set_Draw_Colour ((0, 0, 0, 255));
   Renderer.Fill (Rectangle => (0, 0, Width, Height));
   Renderer.Set_Draw_Colour ((255, 255, 0, 255));
   Renderer.Draw (Point => (X => Random_Width.Random (Width_Gen),
                            Y => Random_Height.Random (Height_Gen)));
   Window.Update_Surface;

   Wait;
   Window.Finalize;
   SDL.Finalise;
end Draw_A_Pixel_2;
Task: Words containing _the_ substring







Python: import urllib.request as request

with request.urlopen("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") as f:
    a = f.read().decode("ASCII").split()

for s in a:
    if len(s) > 11 and "the" in s:
        print(s)





Ada: with Ada.Text_IO;            use Ada.Text_IO;
with Ada.Strings.Fixed;      use Ada.Strings.Fixed;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;

procedure Main is
   type col_count is mod 6;
   package AF renames Ada.Strings.Fixed;

   file_name : String             := "unixdict.txt";
   The_File  : File_Type;
   Inpt_Str  : String (1 .. 40);
   Length    : Natural;
   pattern   : String             := "the";
   Columns   : col_count          := 0;
   Tally     : Natural            := 0;
   sep       : constant Character := HT;
begin

   Open (File => The_File, Mode => In_File, Name => file_name);

   while not End_Of_File (The_File) loop
      Get_Line (File => The_File, Item => Inpt_Str, Last => Length);

      if Length > 11
        and then
          AF.Count (Source => Inpt_Str (1 .. Length), Pattern => pattern) > 0
      then
         Tally   := Tally + 1;
         Columns := Columns + 1;
         Put (Inpt_Str (1 .. Length) & sep);
         if Columns = 0 then
            New_Line;
         end if;
      end if;
   end loop;
   New_Line;
   Put_Line ("Found" & Tally'Image & " ""the"" words");
   Close (The_File);
end Main;
Task: Four sides of square







Python: size = 9
for row in range(size):
    for col in range(size):
        if row == 0 or row == size-1 or col == 0 or col == size-1:
            print("1", end=" ")
        else:
            print("0", end=" ")
    print()





Ada: with Ada.Text_Io;
with Ada.Command_Line;

procedure Four_Sides is

   type Matrix_Type is array (Natural range <>, Natural range <>) of Character;

   function Hollow (Length : Natural) return Matrix_Type is
   begin
      return M : Matrix_Type (1 .. Length, 1 .. Length) do
         for Row in M'Range(1) loop
            for Col in M'Range (2) loop
               M (Row, Col) := (if Row in M'First (1) | M'Last (1) or
                                  Col in M'First (2) | M'Last (2)
                                then '1' else '0');
            end loop;
         end loop;
      end return;
   end Hollow;

   procedure Put (M : Matrix_Type) is
   begin
      for Row in M'Range (1) loop
         for Col in M'Range (2) loop
            Ada.Text_Io.Put (" ");
            Ada.Text_Io.Put (M(Row,Col));
         end loop;
         Ada.Text_Io.New_Line;
      end loop;
   end Put;

begin
   Put (Hollow (Length => Natural'Value (Ada.Command_Line.Argument (1))));
exception
   when others =>
      Ada.Text_Io.Put_Line ("Usage: ./four_sides <length>");
end Four_Sides;
Task: Longest common suffix







Python: 

from itertools import takewhile
from functools import reduce



def longestCommonSuffix(xs):
    
    def allSame(cs):
        h = cs[0]
        return all(h == c for c in cs[1:])

    def firstCharPrepended(s, cs):
        return cs[0] + s
    return reduce(
        firstCharPrepended,
        takewhile(
            allSame,
            zip(*(reversed(x) for x in xs))
        ),
        ''
    )




def main():
    

    samples = [
        [
            "Sunday", "Monday", "Tuesday", "Wednesday",
            "Thursday", "Friday", "Saturday"
        ], [
            "Sondag", "Maandag", "Dinsdag", "Woensdag",
            "Donderdag", "Vrydag", "Saterdag"
        ]
    ]
    for xs in samples:
        print(
            longestCommonSuffix(xs)
        )



if __name__ == '__main__':
    main()





Ada: with Ada.Strings.Unbounded;
with Ada.Text_Io.Unbounded_IO;

procedure Longest_Common_Suffix is
   use Ada.Text_Io;
   use Ada.Text_Io.Unbounded_Io;
   use Ada.Strings.Unbounded;

   subtype Ustring is Unbounded_String;

   function "+"(S : String) return Ustring
     renames To_Unbounded_String;

   type String_List is array (Positive range <>) of Ustring;

   function Longest_Suffix (List : String_List) return Ustring is
      Suffix : Ustring := List (List'First);
   begin
      for A in List'First + 1 .. List'Last loop
         declare
            Word  : Ustring renames List (A);
            Found : Boolean := False;
            Len   : constant Natural :=
              Natural'Min (Length (Suffix), Length (Word));
         begin
            for P in reverse 1 .. Len loop
               if Tail (Suffix, P) = Tail (Word, P) then
                  Suffix := Tail (Word, P);
                  Found := True;
                  exit;
               end if;
            end loop;
            if not Found then
               Suffix := +"";
            end if;
         end;
      end loop;
      return Suffix;
   end Longest_Suffix;

   procedure Put (List : String_List) is
   begin
      Put ("[");
      for S of List loop
         Put ("'"); Put (S); Put ("' ");
      end loop;
      Put ("]");
   end Put;

   procedure Test (List : String_List) is
   begin
      Put (List); Put (" -> '");
      Put (Longest_Suffix (List));
      Put ("'");
      New_Line;
   end Test;

   Case_1 : constant String_List := (+"baabababc", +"baabc", +"bbbabc");
   Case_2 : constant String_List := (+"baabababc", +"baabc", +"bbbazc");
   Case_3 : Constant String_List := (+"Sunday", +"Monday", +"Tuesday",
                                     +"Wednesday", +"Thursday", +"Friday",
                                     +"Saturday");
   Case_4 : constant String_List := (+"longest", +"common", +"suffix");
   Case_5 : constant String_List := (1 => +"suffix");
   Case_6 : Constant String_List := (1 => +"");
begin
   Test (Case_1);
   Test (Case_2);
   Test (Case_3);
   Test (Case_4);
   Test (Case_5);
   Test (Case_6);
end Longest_Common_Suffix;
Task: Distinct power numbers







Python: from itertools import product
print(sorted(set(a**b for (a,b) in product(range(2,6), range(2,6)))))





Ada: with Ada.Text_Io;
with Ada.Containers.Doubly_Linked_Lists;

procedure Power_Numbers is

   package Number_Lists   is new Ada.Containers.Doubly_Linked_Lists (Integer);
   package Number_Sorting is new Number_Lists.Generic_Sorting;
   use Number_Lists, Ada.Text_Io;

   List : Number_Lists.List;
begin
   for A in 2 .. 5 loop
      for B in 2 .. 5 loop
         declare
            R : constant Integer := A**B;
         begin
            if not List.Contains (R) then
               List.Append (R);
            end if;
         end;
      end loop;
   end loop;

   Number_Sorting.Sort (List);

   for E of List loop
      Put (Integer'Image (E));
      Put (" ");
   end loop;
   New_Line;

end Power_Numbers;