WeixiangYan/CodeTransOcean huggingface dataset:
Task: Totient function








VB: Private Function totient(ByVal n As Long) As Long
    Dim tot As Long: tot = n
    Dim i As Long: i = 2
    Do While i * i <= n
        If n Mod i = 0 Then
            Do While True
                n = n \ i
                If n Mod i <> 0 Then Exit Do
            Loop
            tot = tot - tot \ i
        End If
        i = i + IIf(i = 2, 1, 2)
    Loop
    If n > 1 Then
        tot = tot - tot \ n
    End If
    totient = tot
End Function

Public Sub main()
    Debug.Print " n  phi   prime"
    Debug.Print " --------------"
    Dim count As Long
    Dim tot As Integer, n As Long
    For n = 1 To 25
        tot = totient(n)
        prime = (n - 1 = tot)
        count = count - prime
        Debug.Print Format(n, "@@"); Format(tot, "@@@@@"); Format(prime, "@@@@@@@@")
    Next n
    Debug.Print
    Debug.Print "Number of primes up to 25     = "; Format(count, "@@@@")
    For n = 26 To 100000
        count = count - (totient(n) = n - 1)
        Select Case n
            Case 100, 1000, 10000, 100000
                Debug.Print "Number of primes up to"; n; String$(6 - Len(CStr(n)), " "); "="; Format(count, "@@@@@")
            Case Else
        End Select
    Next n
End Sub
Task: Totient function




Go: package main

import "fmt"

func gcd(n, k int) int {
    if n < k || k < 1 {
        panic("Need n >= k and k >= 1")
    }

    s := 1
    for n&1 == 0 && k&1 == 0 {
        n >>= 1
        k >>= 1
        s <<= 1
    }

    t := n
    if n&1 != 0 {
        t = -k
    }
    for t != 0 {
        for t&1 == 0 {
            t >>= 1
        }
        if t > 0 {
            n = t
        } else {
            k = -t
        }
        t = n - k
    }
    return n * s
}

func totient(n int) int {
    tot := 0
    for k := 1; k <= n; k++ {
        if gcd(n, k) == 1 {
            tot++
        }
    }
    return tot
}

func main() {
    fmt.Println(" n  phi   prime")
    fmt.Println("---------------")
    count := 0
    for n := 1; n <= 25; n++ {
        tot := totient(n)
        isPrime := n-1 == tot
        if isPrime {
            count++
        }
        fmt.Printf("%2d   %2d   %t\n", n, tot, isPrime)
    }
    fmt.Println("\nNumber of primes up to 25     =", count)
    for n := 26; n <= 100000; n++ {
        tot := totient(n)
        if tot == n-1 {
            count++
        }
        if n == 100 || n == 1000 || n%10000 == 0 {
            fmt.Printf("\nNumber of primes up to %-6d = %d\n", n, count)
        }
    }
}
Task: Determine if a string is numeric



C#: public static bool IsNumeric(string s)
{
    double Result;
    return double.TryParse(s, out Result);  
}        

string value = "123";
if (IsNumeric(value)) 
{
  
}









Ada: package Numeric_Tests is
   function Is_Numeric (Item : in String) return Boolean;
end Numeric_Tests;
Task: Determine if a string is numeric

C: #include <ctype.h>
#include <stdlib.h>
int isNumeric (const char * s)
{
    if (s == NULL || *s == '\0' || isspace(*s))
      return 0;
    char * p;
    strtod (s, &p);
    return *p == '\0';
}











Ada: package Numeric_Tests is
   function Is_Numeric (Item : in String) return Boolean;
end Numeric_Tests;
Task: Determine if a string is numeric


C++: #include <sstream> 

using namespace std;

bool isNumeric( const char* pszInput, int nNumberBase )
{
	istringstream iss( pszInput );

	if ( nNumberBase == 10 )
	{
		double dTestSink;
		iss >> dTestSink;
	}
	else if ( nNumberBase == 8 || nNumberBase == 16 )
	{
		int nTestSink;
		iss >> ( ( nNumberBase == 8 ) ? oct : hex ) >> nTestSink;
	}
	else
		return false;

	
	if ( ! iss )
		return false;

	
	return ( iss.rdbuf()->in_avail() == 0 );
}










Ada: package Numeric_Tests is
   function Is_Numeric (Item : in String) return Boolean;
end Numeric_Tests;
Task: Determine if a string is numeric




Go: package main

import (
    "fmt"
    "strconv"
)

func isNumeric(s string) bool {
    _, err := strconv.ParseFloat(s, 64)
    return err == nil
}

func main() {
    fmt.Println("Are these strings numeric?")
    strings := []string{"1", "3.14", "-100", "1e2", "NaN", "rose"}
    for _, s := range strings {
        fmt.Printf("  %4s -> %t\n", s, isNumeric(s))
    }
}








Ada: package Numeric_Tests is
   function Is_Numeric (Item : in String) return Boolean;
end Numeric_Tests;
Task: Determine if a string is numeric





Java: public boolean isNumeric(String input) {
  try {
    Integer.parseInt(input);
    return true;
  }
  catch (NumberFormatException e) {
    
    return false;
  }
}







Ada: package Numeric_Tests is
   function Is_Numeric (Item : in String) return Boolean;
end Numeric_Tests;
Task: Determine if a string is numeric







Python: def is_numeric(s):
    try:
        float(s)
        return True
    except (ValueError, TypeError):
        return False

is_numeric('123.0')





Ada: package Numeric_Tests is
   function Is_Numeric (Item : in String) return Boolean;
end Numeric_Tests;
Task: Determine if a string is numeric








VB: Sub Main()
    Debug.Print Is_Numeric("")
    Debug.Print Is_Numeric("-5.32")
    Debug.Print Is_Numeric("-51,321 32")
    Debug.Print Is_Numeric("123.4")
    Debug.Print Is_Numeric("123,4")
    Debug.Print Is_Numeric("123;4")
    Debug.Print Is_Numeric("123.4x")
End Sub

Private Function Is_Numeric(s As String) As Boolean
Dim Separat As String, Other As String
    Separat = Application.DecimalSeparator
    Other = IIf(Separat = ",", ".", ",")
    Is_Numeric = IsNumeric(Replace(s, Other, Separat))
End Function




Ada: package Numeric_Tests is
   function Is_Numeric (Item : in String) return Boolean;
end Numeric_Tests;
Task: Determine if a string is numeric

C: #include <ctype.h>
#include <stdlib.h>
int isNumeric (const char * s)
{
    if (s == NULL || *s == '\0' || isspace(*s))
      return 0;
    char * p;
    strtod (s, &p);
    return *p == '\0';
}
Task: Determine if a string is numeric



C#: public static bool IsNumeric(string s)
{
    double Result;
    return double.TryParse(s, out Result);  
}        

string value = "123";
if (IsNumeric(value)) 
{
  
}
Task: Determine if a string is numeric


C++: #include <sstream> 

using namespace std;

bool isNumeric( const char* pszInput, int nNumberBase )
{
	istringstream iss( pszInput );

	if ( nNumberBase == 10 )
	{
		double dTestSink;
		iss >> dTestSink;
	}
	else if ( nNumberBase == 8 || nNumberBase == 16 )
	{
		int nTestSink;
		iss >> ( ( nNumberBase == 8 ) ? oct : hex ) >> nTestSink;
	}
	else
		return false;

	
	if ( ! iss )
		return false;

	
	return ( iss.rdbuf()->in_avail() == 0 );
}
Task: Determine if a string is numeric





Java: public boolean isNumeric(String input) {
  try {
    Integer.parseInt(input);
    return true;
  }
  catch (NumberFormatException e) {
    
    return false;
  }
}
Task: Determine if a string is numeric







Python: def is_numeric(s):
    try:
        float(s)
        return True
    except (ValueError, TypeError):
        return False

is_numeric('123.0')
Task: Determine if a string is numeric








VB: Sub Main()
    Debug.Print Is_Numeric("")
    Debug.Print Is_Numeric("-5.32")
    Debug.Print Is_Numeric("-51,321 32")
    Debug.Print Is_Numeric("123.4")
    Debug.Print Is_Numeric("123,4")
    Debug.Print Is_Numeric("123;4")
    Debug.Print Is_Numeric("123.4x")
End Sub

Private Function Is_Numeric(s As String) As Boolean
Dim Separat As String, Other As String
    Separat = Application.DecimalSeparator
    Other = IIf(Separat = ",", ".", ",")
    Is_Numeric = IsNumeric(Replace(s, Other, Separat))
End Function
Task: Determine if a string is numeric




Go: package main

import (
    "fmt"
    "strconv"
)

func isNumeric(s string) bool {
    _, err := strconv.ParseFloat(s, 64)
    return err == nil
}

func main() {
    fmt.Println("Are these strings numeric?")
    strings := []string{"1", "3.14", "-100", "1e2", "NaN", "rose"}
    for _, s := range strings {
        fmt.Printf("  %4s -> %t\n", s, isNumeric(s))
    }
}
Task: Determine if a string is numeric



C#: public static bool IsNumeric(string s)
{
    double Result;
    return double.TryParse(s, out Result);  
}        

string value = "123";
if (IsNumeric(value)) 
{
  
}








Fortran: FUNCTION is_numeric(string)
  IMPLICIT NONE
  CHARACTER(len=*), INTENT(IN) :: string
  LOGICAL :: is_numeric
  REAL :: x
  INTEGER :: e
  READ(string,*,IOSTAT=e) x
  is_numeric = e == 0
END FUNCTION is_numeric
Task: Determine if a string is numeric


C++: #include <sstream> 

using namespace std;

bool isNumeric( const char* pszInput, int nNumberBase )
{
	istringstream iss( pszInput );

	if ( nNumberBase == 10 )
	{
		double dTestSink;
		iss >> dTestSink;
	}
	else if ( nNumberBase == 8 || nNumberBase == 16 )
	{
		int nTestSink;
		iss >> ( ( nNumberBase == 8 ) ? oct : hex ) >> nTestSink;
	}
	else
		return false;

	
	if ( ! iss )
		return false;

	
	return ( iss.rdbuf()->in_avail() == 0 );
}









Fortran: FUNCTION is_numeric(string)
  IMPLICIT NONE
  CHARACTER(len=*), INTENT(IN) :: string
  LOGICAL :: is_numeric
  REAL :: x
  INTEGER :: e
  READ(string,*,IOSTAT=e) x
  is_numeric = e == 0
END FUNCTION is_numeric
Task: Determine if a string is numeric

C: #include <ctype.h>
#include <stdlib.h>
int isNumeric (const char * s)
{
    if (s == NULL || *s == '\0' || isspace(*s))
      return 0;
    char * p;
    strtod (s, &p);
    return *p == '\0';
}










Fortran: FUNCTION is_numeric(string)
  IMPLICIT NONE
  CHARACTER(len=*), INTENT(IN) :: string
  LOGICAL :: is_numeric
  REAL :: x
  INTEGER :: e
  READ(string,*,IOSTAT=e) x
  is_numeric = e == 0
END FUNCTION is_numeric
Task: Determine if a string is numeric





Java: public boolean isNumeric(String input) {
  try {
    Integer.parseInt(input);
    return true;
  }
  catch (NumberFormatException e) {
    
    return false;
  }
}






Fortran: FUNCTION is_numeric(string)
  IMPLICIT NONE
  CHARACTER(len=*), INTENT(IN) :: string
  LOGICAL :: is_numeric
  REAL :: x
  INTEGER :: e
  READ(string,*,IOSTAT=e) x
  is_numeric = e == 0
END FUNCTION is_numeric
Task: Determine if a string is numeric







Python: def is_numeric(s):
    try:
        float(s)
        return True
    except (ValueError, TypeError):
        return False

is_numeric('123.0')




Fortran: FUNCTION is_numeric(string)
  IMPLICIT NONE
  CHARACTER(len=*), INTENT(IN) :: string
  LOGICAL :: is_numeric
  REAL :: x
  INTEGER :: e
  READ(string,*,IOSTAT=e) x
  is_numeric = e == 0
END FUNCTION is_numeric
Task: Determine if a string is numeric








VB: Sub Main()
    Debug.Print Is_Numeric("")
    Debug.Print Is_Numeric("-5.32")
    Debug.Print Is_Numeric("-51,321 32")
    Debug.Print Is_Numeric("123.4")
    Debug.Print Is_Numeric("123,4")
    Debug.Print Is_Numeric("123;4")
    Debug.Print Is_Numeric("123.4x")
End Sub

Private Function Is_Numeric(s As String) As Boolean
Dim Separat As String, Other As String
    Separat = Application.DecimalSeparator
    Other = IIf(Separat = ",", ".", ",")
    Is_Numeric = IsNumeric(Replace(s, Other, Separat))
End Function



Fortran: FUNCTION is_numeric(string)
  IMPLICIT NONE
  CHARACTER(len=*), INTENT(IN) :: string
  LOGICAL :: is_numeric
  REAL :: x
  INTEGER :: e
  READ(string,*,IOSTAT=e) x
  is_numeric = e == 0
END FUNCTION is_numeric
Task: Determine if a string is numeric






PHP: <?php
$string = '123';
if(is_numeric(trim($string))) {
}
?>





Fortran: FUNCTION is_numeric(string)
  IMPLICIT NONE
  CHARACTER(len=*), INTENT(IN) :: string
  LOGICAL :: is_numeric
  REAL :: x
  INTEGER :: e
  READ(string,*,IOSTAT=e) x
  is_numeric = e == 0
END FUNCTION is_numeric
Task: Determine if a string is numeric

C: #include <ctype.h>
#include <stdlib.h>
int isNumeric (const char * s)
{
    if (s == NULL || *s == '\0' || isspace(*s))
      return 0;
    char * p;
    strtod (s, &p);
    return *p == '\0';
}









COBOL:         program-id. is-numeric.
        procedure division.
        display function test-numval-f("abc") end-display
        display function test-numval-f("-123.01E+3") end-display
        if function test-numval-f("+123.123") equal zero then
            display "is numeric" end-display
        else
            display "failed numval-f test" end-display
        end-if
        goback.
Task: Determine if a string is numeric



C#: public static bool IsNumeric(string s)
{
    double Result;
    return double.TryParse(s, out Result);  
}        

string value = "123";
if (IsNumeric(value)) 
{
  
}







COBOL:         program-id. is-numeric.
        procedure division.
        display function test-numval-f("abc") end-display
        display function test-numval-f("-123.01E+3") end-display
        if function test-numval-f("+123.123") equal zero then
            display "is numeric" end-display
        else
            display "failed numval-f test" end-display
        end-if
        goback.
Task: Determine if a string is numeric


C++: #include <sstream> 

using namespace std;

bool isNumeric( const char* pszInput, int nNumberBase )
{
	istringstream iss( pszInput );

	if ( nNumberBase == 10 )
	{
		double dTestSink;
		iss >> dTestSink;
	}
	else if ( nNumberBase == 8 || nNumberBase == 16 )
	{
		int nTestSink;
		iss >> ( ( nNumberBase == 8 ) ? oct : hex ) >> nTestSink;
	}
	else
		return false;

	
	if ( ! iss )
		return false;

	
	return ( iss.rdbuf()->in_avail() == 0 );
}








COBOL:         program-id. is-numeric.
        procedure division.
        display function test-numval-f("abc") end-display
        display function test-numval-f("-123.01E+3") end-display
        if function test-numval-f("+123.123") equal zero then
            display "is numeric" end-display
        else
            display "failed numval-f test" end-display
        end-if
        goback.
Task: Determine if a string is numeric





Java: public boolean isNumeric(String input) {
  try {
    Integer.parseInt(input);
    return true;
  }
  catch (NumberFormatException e) {
    
    return false;
  }
}





COBOL:         program-id. is-numeric.
        procedure division.
        display function test-numval-f("abc") end-display
        display function test-numval-f("-123.01E+3") end-display
        if function test-numval-f("+123.123") equal zero then
            display "is numeric" end-display
        else
            display "failed numval-f test" end-display
        end-if
        goback.
Task: Determine if a string is numeric







Python: def is_numeric(s):
    try:
        float(s)
        return True
    except (ValueError, TypeError):
        return False

is_numeric('123.0')



COBOL:         program-id. is-numeric.
        procedure division.
        display function test-numval-f("abc") end-display
        display function test-numval-f("-123.01E+3") end-display
        if function test-numval-f("+123.123") equal zero then
            display "is numeric" end-display
        else
            display "failed numval-f test" end-display
        end-if
        goback.
Task: Determine if a string is numeric








VB: Sub Main()
    Debug.Print Is_Numeric("")
    Debug.Print Is_Numeric("-5.32")
    Debug.Print Is_Numeric("-51,321 32")
    Debug.Print Is_Numeric("123.4")
    Debug.Print Is_Numeric("123,4")
    Debug.Print Is_Numeric("123;4")
    Debug.Print Is_Numeric("123.4x")
End Sub

Private Function Is_Numeric(s As String) As Boolean
Dim Separat As String, Other As String
    Separat = Application.DecimalSeparator
    Other = IIf(Separat = ",", ".", ",")
    Is_Numeric = IsNumeric(Replace(s, Other, Separat))
End Function


COBOL:         program-id. is-numeric.
        procedure division.
        display function test-numval-f("abc") end-display
        display function test-numval-f("-123.01E+3") end-display
        if function test-numval-f("+123.123") equal zero then
            display "is numeric" end-display
        else
            display "failed numval-f test" end-display
        end-if
        goback.
Task: Determine if a string is numeric




Go: package main

import (
    "fmt"
    "strconv"
)

func isNumeric(s string) bool {
    _, err := strconv.ParseFloat(s, 64)
    return err == nil
}

func main() {
    fmt.Println("Are these strings numeric?")
    strings := []string{"1", "3.14", "-100", "1e2", "NaN", "rose"}
    for _, s := range strings {
        fmt.Printf("  %4s -> %t\n", s, isNumeric(s))
    }
}






COBOL:         program-id. is-numeric.
        procedure division.
        display function test-numval-f("abc") end-display
        display function test-numval-f("-123.01E+3") end-display
        if function test-numval-f("+123.123") equal zero then
            display "is numeric" end-display
        else
            display "failed numval-f test" end-display
        end-if
        goback.
Task: Determine if a string is numeric






PHP: <?php
$string = '123';
if(is_numeric(trim($string))) {
}
?>
Task: Determine if a string is numeric






PHP: <?php
$string = '123';
if(is_numeric(trim($string))) {
}
?>






Ada: package Numeric_Tests is
   function Is_Numeric (Item : in String) return Boolean;
end Numeric_Tests;
Task: Determine if a string is numeric






PHP: <?php
$string = '123';
if(is_numeric(trim($string))) {
}
?>




COBOL:         program-id. is-numeric.
        procedure division.
        display function test-numval-f("abc") end-display
        display function test-numval-f("-123.01E+3") end-display
        if function test-numval-f("+123.123") equal zero then
            display "is numeric" end-display
        else
            display "failed numval-f test" end-display
        end-if
        goback.
Task: One-dimensional cellular automata



C#: using System;
using System.Collections.Generic;

namespace prog
{
	class MainClass
	{	
		const int n_iter = 10;
		static int[] f = { 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0 };
		
		public static void Main (string[] args)
		{
			for( int i=0; i<f.Length; i++ )
				Console.Write( f[i]==0 ? "-" : "#" );
			Console.WriteLine("");			
			
			int[] g = new int[f.Length];
			for( int n=n_iter; n!=0; n-- )
			{
				for( int i=1; i<f.Length-1; i++ )
				{
					if ( (f[i-1] ^ f[i+1]) == 1 ) g[i] = f[i];
					else if ( f[i] == 0 && (f[i-1] & f[i+1]) == 1 ) g[i] = 1;
					else g[i] = 0;
				}
				g[0] = ( (f[0] & f[1]) == 1 ) ? 1 : 0;
				g[g.Length-1] = ( (f[f.Length-1] & f[f.Length-2]) == 1 ) ? 1 : 0;
				
				int[] tmp = f;
				f = g;
				g = tmp;
				
				for( int i=0; i<f.Length; i++ )
					Console.Write( f[i]==0 ? "-" : "#" );
				Console.WriteLine("");
			}			
		}
	}
}









Ada: with Ada.Text_IO;  use Ada.Text_IO;

procedure Cellular_Automata is
   type Petri_Dish is array (Positive range <>) of Boolean;

   procedure Step (Culture : in out Petri_Dish) is
      Left  : Boolean := False;
      This  : Boolean;
      Right : Boolean;
   begin
      for Index in Culture'First..Culture'Last - 1 loop
         Right := Culture (Index + 1);
         This  := Culture (Index);
         Culture (Index) := (This and (Left xor Right)) or (not This and Left and Right);
         Left := This;
      end loop;
      Culture (Culture'Last) := Culture (Culture'Last) and not Left;
   end Step;
   
   procedure Put (Culture : Petri_Dish) is
   begin
      for Index in Culture'Range loop
         if Culture (Index) then
            Put ('#');
         else
            Put ('_');
         end if;
      end loop;
   end Put;

   Culture : Petri_Dish :=
      (  False, True, True,  True, False, True,  True, False, True, False, True,
         False, True, False, True, False, False, True, False, False
      );
begin
   for Generation in 0..9 loop
      Put ("Generation" & Integer'Image (Generation) & ' ');
      Put (Culture);
      New_Line;
      Step (Culture);
   end loop;
end Cellular_Automata;
Task: One-dimensional cellular automata

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

char trans[] = "___#_##_";

#define v(i) (cell[i] != '_')
int evolve(char cell[], char backup[], int len)
{
	int i, diff = 0;

	for (i = 0; i < len; i++) {
		
		backup[i] = trans[ v(i-1) * 4 + v(i) * 2 + v(i + 1) ];
		diff += (backup[i] != cell[i]);
	}

	strcpy(cell, backup);
	return diff;
}

int main()
{
	char	c[] = "_###_##_#_#_#_#__#__\n",
		b[] = "____________________\n";

	do { printf(c + 1); } while (evolve(c + 1, b + 1, sizeof(c) - 3));
	return 0;
}











Ada: with Ada.Text_IO;  use Ada.Text_IO;

procedure Cellular_Automata is
   type Petri_Dish is array (Positive range <>) of Boolean;

   procedure Step (Culture : in out Petri_Dish) is
      Left  : Boolean := False;
      This  : Boolean;
      Right : Boolean;
   begin
      for Index in Culture'First..Culture'Last - 1 loop
         Right := Culture (Index + 1);
         This  := Culture (Index);
         Culture (Index) := (This and (Left xor Right)) or (not This and Left and Right);
         Left := This;
      end loop;
      Culture (Culture'Last) := Culture (Culture'Last) and not Left;
   end Step;
   
   procedure Put (Culture : Petri_Dish) is
   begin
      for Index in Culture'Range loop
         if Culture (Index) then
            Put ('#');
         else
            Put ('_');
         end if;
      end loop;
   end Put;

   Culture : Petri_Dish :=
      (  False, True, True,  True, False, True,  True, False, True, False, True,
         False, True, False, True, False, False, True, False, False
      );
begin
   for Generation in 0..9 loop
      Put ("Generation" & Integer'Image (Generation) & ' ');
      Put (Culture);
      New_Line;
      Step (Culture);
   end loop;
end Cellular_Automata;
Task: One-dimensional cellular automata


C++: #include <iostream>
#include <bitset>
#include <string>

const int ArraySize = 20;
const int NumGenerations = 10;
const std::string Initial = "0011101101010101001000";

int main()
{
    
    std::bitset<ArraySize + 2> array(Initial);

    for(int j = 0; j < NumGenerations; ++j)
    {
        std::bitset<ArraySize + 2> tmpArray(array);
        for(int i = ArraySize; i >= 1 ; --i)
        {
            if(array[i])
                std::cout << "#";
            else
                std::cout << "_";
            int val = (int)array[i-1] << 2 | (int)array[i] << 1 | (int)array[i+1];
            tmpArray[i] = (val == 3 || val == 5 || val == 6);
        }
        array = tmpArray;
        std::cout << std::endl;
    }
}










Ada: with Ada.Text_IO;  use Ada.Text_IO;

procedure Cellular_Automata is
   type Petri_Dish is array (Positive range <>) of Boolean;

   procedure Step (Culture : in out Petri_Dish) is
      Left  : Boolean := False;
      This  : Boolean;
      Right : Boolean;
   begin
      for Index in Culture'First..Culture'Last - 1 loop
         Right := Culture (Index + 1);
         This  := Culture (Index);
         Culture (Index) := (This and (Left xor Right)) or (not This and Left and Right);
         Left := This;
      end loop;
      Culture (Culture'Last) := Culture (Culture'Last) and not Left;
   end Step;
   
   procedure Put (Culture : Petri_Dish) is
   begin
      for Index in Culture'Range loop
         if Culture (Index) then
            Put ('#');
         else
            Put ('_');
         end if;
      end loop;
   end Put;

   Culture : Petri_Dish :=
      (  False, True, True,  True, False, True,  True, False, True, False, True,
         False, True, False, True, False, False, True, False, False
      );
begin
   for Generation in 0..9 loop
      Put ("Generation" & Integer'Image (Generation) & ' ');
      Put (Culture);
      New_Line;
      Step (Culture);
   end loop;
end Cellular_Automata;