WeixiangYan/CodeTransOcean huggingface dataset:
Task: Longest substrings without repeating characters

C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

struct substr {
    const char *start;
    size_t length;
};

struct substr *lswrc(const char *str) {
    size_t length = strlen(str);
    struct substr *arr = malloc(sizeof(struct substr) * (length + 1));
    if (!arr) return NULL;
  
    size_t start=0, i=0, maxStart=0, maxEnd=0, n=0;
    bool used[256] = {false};
    
    for (i=0; i<length; i++) {
        while (used[(unsigned char) str[i]]) 
            used[(unsigned char) str[start++]] = false;
        used[(unsigned char) str[i]] = true;
        if (i-start >= maxEnd-maxStart) {
            maxStart = start;
            maxEnd = i;
            size_t len = maxEnd - maxStart + 1;
            while (n>0 && arr[n-1].length < len) n--;
            arr[n].start = &str[start];
            arr[n].length = len;
            n++;
        }
    }
    
    arr[n].start = NULL;
    arr[n].length = 0;
    return realloc(arr, sizeof(struct substr) * (n+1));
}

int main() {
    char *examples[] = {"xyzyabcybdfd", "xyzyab", "zzzzz", "a", "", NULL};
    
    for (size_t i=0; examples[i]; i++) {
        printf("Original string: \"%s\"\n", examples[i]);
        printf("Longest substrings: ");
        struct substr *ls = lswrc(examples[i]);
        for (size_t j=0; ls[j].start; j++)
            printf("\"%.*s\" ", (int)ls[j].length, ls[j].start);
        printf("\n");
        free(ls);
    }
    
    return 0;
}











Ada: with Ada.Text_IO;

procedure Longest_Substring is

   function Longest (Item : String) return String is
      Hist  : array (Character) of Natural := (others => 0);
      First         : Natural := Item'First;
      Last          : Natural := Item'First - 1;
      Longest_First : Natural := Item'First;
      Longest_Last  : Natural := Item'First - 1;

      procedure Adjust is
      begin
         if Last - First > Longest_Last - Longest_First then
            Longest_First := First;
            Longest_Last  := Last;
         end if;
      end Adjust;

   begin
      if Item = "" then
         return Item;
      end if;
      for Index in Item'Range loop
         Last := Index;
         Hist (Item (Index)) := Hist (Item (Index)) + 1;
         if Hist (Item (Index)) = 1 then
            Adjust;
         else
            for A in First .. Index loop
               if (for all E of Hist => E <= 1) then
                  First := A;
                  Adjust;
                  exit;
               end if;

               Hist (Item (A)) := Hist (Item (A)) - 1;
            end loop;
         end if;
      end loop;
      return Item (Longest_First .. Longest_Last);
   end Longest;

   procedure Test (Item : String) is
      use Ada.Text_IO;
   begin
      Put ("original : '");  Put (Item);            Put_Line ("'");
      Put ("longest  : '");  Put (Longest (Item));  Put_Line ("'");
   end Test;

begin
   Test ("");
   Test ("a");
   Test ("xyzyabcybdfd");
   Test ("thisisastringtest");
   Test ("zzzzz");
end Longest_Substring;
Task: Find words with alternating vowels and consonants

C: #include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_WORD_SIZE 80

bool is_vowel(char ch) {
    switch (ch) {
    case 'a': case 'A':
    case 'e': case 'E':
    case 'i': case 'I':
    case 'o': case 'O':
    case 'u': case 'U':
        return true;
    }
    return false;
}

bool alternating_vowels_and_consonants(const char* str, size_t len) {
    for (size_t i = 1; i < len; ++i) {
        if (is_vowel(str[i]) == is_vowel(str[i - 1]))
            return false;
    }
    return true;
}

int main(int argc, char** argv) {
    const char* filename = argc < 2 ? "unixdict.txt" : argv[1];
    FILE* fp = fopen(filename, "r");
    if (!fp) {
        perror(filename);
        return EXIT_FAILURE;
    }
    char line[MAX_WORD_SIZE];
    int n = 1;
    while (fgets(line, sizeof(line), fp)) {
        size_t len = strlen(line) - 1; 
        if (len > 9 && alternating_vowels_and_consonants(line, len))
            printf("%2d: %s", n++, line);
    }
    fclose(fp);
    return EXIT_SUCCESS;
}











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

C: #include<stdlib.h>
#include<stdio.h>

#define LEN 100  

int main()
{
	char **list;
	int num, i;
	
	scanf("%d",&num);
	
	list = (char**)malloc(num*sizeof(char*));
	
	for(i=0;i<num;i++)
	{
	   list[i] = (char*)malloc(LEN*sizeof(char));  
	   fflush(stdin);
	   fgets(list[i],LEN,stdin);
	} 
	
	printf("\n");
	
	for(i=0;i<num;i++)
	{
		printf("%s",list[i]);
	}
	
	return 0;
}











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.

C: #include <stdio.h>

int divisible(int n) {
    int p = 1;
    int c, d;
    
    for (c=n; c; c /= 10) {
        d = c % 10;
        if (!d || n % d) return 0;
        p *= d;
    }
    
    return n % p;
}

int main() {
    int n, c=0;
    
    for (n=1; n<1000; n++) {
        if (divisible(n)) {
            printf("%5d", n);
            if (!(++c % 10)) printf("\n");
        }
    }
    printf("\n");
    
    return 0;
}











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

C: #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>

#define DIGITS 1000
#define NUMSIZE 5

uint8_t randomDigit() {
    uint8_t d;
    do {d = rand() & 0xF;} while (d >= 10);
    return d;
}

int numberAt(uint8_t *d, int size) {
    int acc = 0;
    while (size--) acc = 10*acc + *d++;
    return acc;
}

int main() {
    uint8_t digits[DIGITS];
    int i, largest = 0;
    
    srand(time(NULL));
    
    for (i=0; i<DIGITS; i++) digits[i] = randomDigit();
    for (i=0; i<DIGITS-NUMSIZE; i++) {
        int here = numberAt(&digits[i], NUMSIZE);
        if (here > largest) largest = here;
    }

    printf("%d\n", largest);
    return 0;
}











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

C: #define PI 3.14159265358979323846
#define ABS(x)  (x<0?-x:x)

double arc_length(double radius, double angle1, double angle2) {
    return (360 - ABS(angle2 - angle1)) * PI / 180 * radius;
}

void main()
{
    printf("%.7f\n",arc_length(10, 10, 120));
}











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

C: #include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
    int aa = *(const int *)a;
    int bb = *(const int *)b;
    if (aa < bb) return -1;
    if (aa > bb) return 1;
    return 0;
}

int main() {
    int a[] = {6, 81, 243, 14, 25, 49, 123, 69, 11};
    int isize = sizeof(int);
    int asize = sizeof(a) / isize;
    int i, sum;
    while (asize > 1) {
        qsort(a, asize, isize, compare);
        printf("Sorted list: ");
        for (i = 0; i < asize; ++i) printf("%d ", a[i]);
        printf("\n");
        sum = a[0] + a[1];
        printf("Two smallest: %d + %d = %d\n", a[0], a[1], sum);
        for (i = 2; i < asize; ++i) a[i-2] = a[i];
        a[asize - 2] = sum;
        asize--;
    }
    printf("Last item is %d.\n", a[0]);
    return 0;
}











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

C: #include <stdio.h>


void lshift(int *l, size_t n) {
    int i, f;
    if (n < 2) return;
    f = l[0];
    for (i = 0; i < n-1; ++i) l[i] = l[i+1];
    l[n-1] = f;
}

int main() {
    int l[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    int i;
    size_t n = 9;
    printf("Original list     : ");
    for (i = 0; i < n; ++i) printf("%d ", l[i]);
    printf("\nShifted left by 3 : ");
    for (i = 0; i < 3; ++i) lshift(l, n);
    for (i = 0; i < n; ++i) printf("%d ", l[i]);
    printf("\n");
    return 0;
}











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

C: #include <stdio.h>
#define LIMIT 100000

int digitset(int num, int base) {
    int set;
    for (set = 0; num; num /= base)
        set |= 1 << num % base;
    return set;
}

int main() {
    int i, c = 0;
    for (i = 0; i < LIMIT; i++)
        if (digitset(i,10) == digitset(i,16))
            printf("%6d%c", i, ++c%10 ? ' ' : '\n');
    printf("\n");
    return 0;
}











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

C: #include <math.h>
#include <stdio.h>

#define DEG 0.017453292519943295769236907684886127134  
#define RE 6371000.0 
#define DD 0.001 
#define FIN 10000000.0 

static double rho(double a) {
    
    return exp(-a / 8500.0);
}

static double height(double a, double z, double d) {
    
    
    
    double aa = RE + a;
    double hh = sqrt(aa * aa + d * d - 2.0 * d * aa * cos((180 - z) * DEG));
    return hh - RE;
}

static double column_density(double a, double z) {
    
    double sum = 0.0, d = 0.0;
    while (d < FIN) {
        
        double delta = DD * d;
        if (delta < DD)
            delta = DD;
        sum += rho(height(a, z, d + 0.5 * delta)) * delta;
        d += delta;
    }
    return sum;
}

static double airmass(double a, double z) {
    return column_density(a, z) / column_density(a, 0.0);
}

int main() {
    puts("Angle     0 m              13700 m");
    puts("------------------------------------");
    for (double z = 0; z <= 90; z+= 5) {
        printf("%2.0f      %11.8f      %11.8f\n",
               z, airmass(0.0, z), airmass(13700.0, z));
    }
}











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: Aspect oriented programming

C: #define MY_NEW_FEATURE_ENABLED

...

#ifdef MY_NEW_FEATURE_ENABLED
  my_new_feature();
#endif

...

#ifdef MY_NEW_FEATURE_ENABLED
  close_my_new_feature();
#endif











Ada: package parent is
   function Add2 (X : in Integer) return Integer;
end parent;
Task: Matrix with two diagonals

C: #include <stdio.h>

void specialMatrix(unsigned int n) {
    int i, j;
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            if (i == j || i + j == n - 1) {
                printf("%d ", 1);
            } else {
                printf("%d ", 0);
            }
        }
        printf("\n");
    }
}

int main() {
    specialMatrix(10); 
    printf("\n");
    specialMatrix(11); 
    return 0;
}











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

C: #include<graphics.h>
#include<stdlib.h>
#include<time.h>

int main()
{
	srand(time(NULL));
	
	initwindow(640,480,"Yellow Random Pixel");
	
	putpixel(rand()%640,rand()%480,YELLOW);
	
	getch();
	
	return 0;
}











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

C: #include <stdio.h>
#include <string.h>

int main() {
    char word[128];
    FILE *f = fopen("unixdict.txt","r");
    if (!f) {
        fprintf(stderr, "Cannot open unixdict.txt\n");
        return -1;
    }
    while (!feof(f)) {
        fgets(word, sizeof(word), f);
        
        
        if (strlen(word) > 12 && strstr(word,"the"))
            printf("%s",word);
    }
    fclose(f);
    return 0;
}











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;