WeixiangYan/CodeTransOcean huggingface dataset:
Task: Loops_Foreach





Java: module LoopForEach
    {
    @Inject Console console;
    void run()
        {
        val vals = [10, 20, 30, 40];
        console.print("Array of values:");
        Loop: for (val val : vals)
            {
            console.print($"  value #{Loop.count + 1}: {val}");
            }

        Map<String, Int> pairs = ["x"=42, "y"=69];
        console.print("\nKeys and values:");
        for ((String key, Int val) : pairs)
            {
            console.print($"  {key}={val}");
            }
        console.print("\nJust the keys:");
        Loop: for (String key : pairs)
            {
            console.print($"  key #{Loop.count + 1}: {key}");
            }

        console.print("\nValues from a range:");
        for (Int n : 1..5)
            {
            console.print($"  {n}");
            }
        }
    }






Fortran: program main

 implicit none

 integer :: i
 character(len=5),dimension(5),parameter :: colors = ['Red  ','Green','Blue ','Black','White']

 
 do i=1,size(colors)
   write(*,'(A)') colors(i) 
 end do

 
 write(*,'(A)') colors

end program main
Task: Loops_Foreach







Python: for i in collection:
   print i




Fortran: program main

 implicit none

 integer :: i
 character(len=5),dimension(5),parameter :: colors = ['Red  ','Green','Blue ','Black','White']

 
 do i=1,size(colors)
   write(*,'(A)') colors(i) 
 end do

 
 write(*,'(A)') colors

end program main
Task: Loops_Foreach








VB: Public Sub LoopsForeach()
    Dim FruitArray() As Variant
    Dim Fruit As Variant
    FruitArray = [{"Apple","Banana","Strawberry"}]
    Dim FruitBasket As Collection
    Set FruitBasket = New Collection
    For Each Fruit In FruitArray
        FruitBasket.Add Fruit
    Next Fruit
    For Each Fruit In FruitBasket
        Debug.Print Fruit
    Next Fruit
End Sub



Fortran: program main

 implicit none

 integer :: i
 character(len=5),dimension(5),parameter :: colors = ['Red  ','Green','Blue ','Black','White']

 
 do i=1,size(colors)
   write(*,'(A)') colors(i) 
 end do

 
 write(*,'(A)') colors

end program main
Task: Loops_Foreach






PHP: foreach ($collect as $i) {
   echo "$i\n";
}

foreach ($collect as $key => $i) {
   echo "\$collect[$key] = $i\n";
}





Fortran: program main

 implicit none

 integer :: i
 character(len=5),dimension(5),parameter :: colors = ['Red  ','Green','Blue ','Black','White']

 
 do i=1,size(colors)
   write(*,'(A)') colors(i) 
 end do

 
 write(*,'(A)') colors

end program main
Task: Loops_Foreach

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

const char *list[] = {"Red","Green","Blue","Black","White"};
#define LIST_SIZE (sizeof(list)/sizeof(list[0]))

int ix;
for(ix=0; ix<LIST_SIZE; ix++) {
   printf("%s\n", list[ix]);
}









COBOL: 01  things occurs 3.
...
set content of things to ("Apple", "Banana", "Coconut")
perform varying thing as string through things
    display thing
end-perform
Task: Loops_Foreach



C#: string[] things = {"Apple", "Banana", "Coconut"};

foreach (string thing in things)
{
    Console.WriteLine(thing);
}







COBOL: 01  things occurs 3.
...
set content of things to ("Apple", "Banana", "Coconut")
perform varying thing as string through things
    display thing
end-perform
Task: Loops_Foreach


C++: for (container_type::iterator i = container.begin(); i != container.end(); ++i)
{
  std::cout << *i << "\n";
}








COBOL: 01  things occurs 3.
...
set content of things to ("Apple", "Banana", "Coconut")
perform varying thing as string through things
    display thing
end-perform
Task: Loops_Foreach





Java: module LoopForEach
    {
    @Inject Console console;
    void run()
        {
        val vals = [10, 20, 30, 40];
        console.print("Array of values:");
        Loop: for (val val : vals)
            {
            console.print($"  value #{Loop.count + 1}: {val}");
            }

        Map<String, Int> pairs = ["x"=42, "y"=69];
        console.print("\nKeys and values:");
        for ((String key, Int val) : pairs)
            {
            console.print($"  {key}={val}");
            }
        console.print("\nJust the keys:");
        Loop: for (String key : pairs)
            {
            console.print($"  key #{Loop.count + 1}: {key}");
            }

        console.print("\nValues from a range:");
        for (Int n : 1..5)
            {
            console.print($"  {n}");
            }
        }
    }





COBOL: 01  things occurs 3.
...
set content of things to ("Apple", "Banana", "Coconut")
perform varying thing as string through things
    display thing
end-perform
Task: Loops_Foreach







Python: for i in collection:
   print i



COBOL: 01  things occurs 3.
...
set content of things to ("Apple", "Banana", "Coconut")
perform varying thing as string through things
    display thing
end-perform
Task: Loops_Foreach








VB: Public Sub LoopsForeach()
    Dim FruitArray() As Variant
    Dim Fruit As Variant
    FruitArray = [{"Apple","Banana","Strawberry"}]
    Dim FruitBasket As Collection
    Set FruitBasket = New Collection
    For Each Fruit In FruitArray
        FruitBasket.Add Fruit
    Next Fruit
    For Each Fruit In FruitBasket
        Debug.Print Fruit
    Next Fruit
End Sub


COBOL: 01  things occurs 3.
...
set content of things to ("Apple", "Banana", "Coconut")
perform varying thing as string through things
    display thing
end-perform
Task: Loops_Foreach




Go: func printAll(values []int) {
   for i, x := range values {
      fmt.Printf("Item %d = %d\n", i, x)
   }
}






COBOL: 01  things occurs 3.
...
set content of things to ("Apple", "Banana", "Coconut")
perform varying thing as string through things
    display thing
end-perform
Task: Loops_Foreach






PHP: foreach ($collect as $i) {
   echo "$i\n";
}

foreach ($collect as $key => $i) {
   echo "\$collect[$key] = $i\n";
}
Task: Loops_Foreach






PHP: foreach ($collect as $i) {
   echo "$i\n";
}

foreach ($collect as $key => $i) {
   echo "\$collect[$key] = $i\n";
}






Ada: with Ada.Integer_Text_IO;
use  Ada.Integer_Text_IO;

procedure For_Each is

   A : array (1..5) of Integer := (-1, 0, 1, 2, 3);

begin

   for Num in A'Range loop
      Put( A (Num) );
   end loop;

end For_Each;
Task: Loops_Foreach






PHP: foreach ($collect as $i) {
   echo "$i\n";
}

foreach ($collect as $key => $i) {
   echo "\$collect[$key] = $i\n";
}




COBOL: 01  things occurs 3.
...
set content of things to ("Apple", "Banana", "Coconut")
perform varying thing as string through things
    display thing
end-perform
Task: Brownian tree

C: #include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <FreeImage.h>

#define NUM_PARTICLES  1000
#define SIZE           800

void draw_brownian_tree(int world[SIZE][SIZE]){
  int px, py; 
  int dx, dy; 
  int i;
 
  
  world[rand() % SIZE][rand() % SIZE] = 1;

  for (i = 0; i < NUM_PARTICLES; i++){
    
    px = rand() % SIZE;
    py = rand() % SIZE;

    while (1){
      
      dx = rand() % 3 - 1;
      dy = rand() % 3 - 1;

      if (dx + px < 0 || dx + px >= SIZE || dy + py < 0 || dy + py >= SIZE){
        
        px = rand() % SIZE;
        py = rand() % SIZE;
      }else if (world[py + dy][px + dx] != 0){
        
        world[py][px] = 1;
        break;
      }else{
        py += dy;
        px += dx;
      }
    }
  }
}

int main(){
  int world[SIZE][SIZE];
  FIBITMAP * img;
  RGBQUAD rgb;
  int x, y;
 
  memset(world, 0, sizeof world);
  srand((unsigned)time(NULL));

  draw_brownian_tree(world);

  img = FreeImage_Allocate(SIZE, SIZE, 32, 0, 0, 0);

  for (y = 0; y < SIZE; y++){
    for (x = 0; x < SIZE; x++){
      rgb.rgbRed = rgb.rgbGreen = rgb.rgbBlue = (world[y][x] ? 255 : 0);
      FreeImage_SetPixelColor(img, x, y, &rgb);
    }
  }
  FreeImage_Save(FIF_BMP, img, "brownian_tree.bmp", 0);
  FreeImage_Unload(img);
}
Task: Brownian tree





Java: import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.*;
import javax.swing.JFrame;

public class BrownianTree extends JFrame implements Runnable {

    BufferedImage I;
    private List<Particle> particles;
    static Random rand = new Random();

    public BrownianTree() {
        super("Brownian Tree");
        setBounds(100, 100, 400, 300);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        I = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
        I.setRGB(I.getWidth() / 2, I.getHeight() / 2, 0xff00);
        particles = new LinkedList<Particle>();
    }

    @Override
    public void paint(Graphics g) {
        g.drawImage(I, 0, 0, this);
    }

    public void run() {
        for (int i = 0; i < 20000; i++) {
            particles.add(new Particle());
        }
        while (!particles.isEmpty()) {
            for (Iterator<Particle> it = particles.iterator(); it.hasNext();) {
                if (it.next().move()) {
                    it.remove();
                }
            }
            repaint();
        }
    }

    public static void main(String[] args) {
        BrownianTree b = new BrownianTree();
        b.setVisible(true);
        new Thread(b).start();
    }

    private class Particle {

        private int x, y;

        private Particle() {
            x = rand.nextInt(I.getWidth());
            y = rand.nextInt(I.getHeight());
        }

        
        private boolean move() {
            int dx = rand.nextInt(3) - 1;
            int dy = rand.nextInt(3) - 1;
            if ((x + dx < 0) || (y + dy < 0)
                    || (y + dy >= I.getHeight()) || (x + dx >= I.getWidth())) {
                return true;
            }
            x += dx;
            y += dy;
            if ((I.getRGB(x, y) & 0xff00) == 0xff00) {
                I.setRGB(x - dx, y - dy, 0xff00);
                return true;
            }
            return false;
        }
    }
}
Task: Brownian tree







Python: SIDESTICK = False

def setup() :
    global is_taken
    size(512, 512)
    background(0)
    is_taken = [[False] * height for _ in range(width)]
    is_taken[width/2][height/2] = True


def draw() :
    x = floor(random(width))
    y = floor(random(height))
    if is_taken[x][y]: 
        return
    while True:
        xp = x + floor(random(-1, 2))
        yp = y + floor(random(-1, 2))
        is_contained = 0 <= xp < width and 0 <= yp < height
        if is_contained and not is_taken[xp][yp]:
            x = xp
            y = yp
            continue
        else:
            if SIDESTICK or (is_contained and is_taken[xp][yp]):
                is_taken[x][y] = True
                set(x, y, color(255))            
            break
        
    if frameCount > width * height:
        noLoop()
Task: Brownian tree




Go: package main

import (
    "fmt"
    "image"
    "image/color"
    "image/png"
    "math/rand"
    "os"
)

const w = 400     
const h = 300     
const n = 15000   
const frost = 255 

var g *image.Gray

func main() {
    g = image.NewGray(image.Rectangle{image.Point{0, 0}, image.Point{w, h}})
    
    g.SetGray(w/3, h/3, color.Gray{frost})
generate:
    for a := 0; a < n; {
        
        rp := image.Point{rand.Intn(w), rand.Intn(h)}
        if g.At(rp.X, rp.Y).(color.Gray).Y == frost {
            
            for {
                rp.X += rand.Intn(3) - 1
                rp.Y += rand.Intn(3) - 1
                
                if !rp.In(g.Rect) {
                    continue generate
                }
                if g.At(rp.X, rp.Y).(color.Gray).Y != frost {
                    break
                }
            }
        } else {
            
            
            for !hasNeighbor(rp) {
                rp.X += rand.Intn(3) - 1
                rp.Y += rand.Intn(3) - 1
                
                if !rp.In(g.Rect) {
                    continue generate
                }
            }
        }
        
        g.SetGray(rp.X, rp.Y, color.Gray{frost})
        a++
        
        if a%100 == 0 {
            fmt.Println(a, "of", n)
        }
    }
    f, err := os.Create("tree.png")
    if err != nil {
        fmt.Println(err)
        return
    }
    err = png.Encode(f, g)
    if err != nil {
        fmt.Println(err)
    }
    f.Close()
}

var n8 = []image.Point{
    {-1, -1}, {-1, 0}, {-1, 1},
    {0, -1}, {0, 1},
    {1, -1}, {1, 0}, {1, 1}}

func hasNeighbor(p image.Point) bool { 
    for _, n := range n8 {
        o := p.Add(n)
        if o.In(g.Rect) && g.At(o.X, o.Y).(color.Gray).Y == frost {
            return true
        }
    }
    return false
}
Task: Brownian tree



C#: using System;
using System.Drawing;

namespace BrownianTree
{
    class Program
    {
        static Bitmap BrownianTree(int size, int numparticles)
        {
            Bitmap bmp = new Bitmap(size, size);
            Rectangle bounds = new Rectangle { X = 0, Y = 0, Size = bmp.Size };
            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.Clear(Color.Black);
            }
            Random rnd = new Random();
            bmp.SetPixel(rnd.Next(size), rnd.Next(size), Color.White);
            Point pt = new Point(), newpt = new Point();
            for (int i = 0; i < numparticles; i++)
            {
                pt.X = rnd.Next(size);
                pt.Y = rnd.Next(size);
                do
                {
                    newpt.X = pt.X + rnd.Next(-1, 2);
                    newpt.Y = pt.Y + rnd.Next(-1, 2);
                    if (!bounds.Contains(newpt))
                    {
                        pt.X = rnd.Next(size);
                        pt.Y = rnd.Next(size);
                    }
                    else if (bmp.GetPixel(newpt.X, newpt.Y).R > 0)
                    {
                        bmp.SetPixel(pt.X, pt.Y, Color.White);
                        break;
                    }
                    else
                    {
                        pt = newpt;
                    }
                } while (true);
            }
            return bmp;
        }

        static void Main(string[] args)
        {
            BrownianTree(300, 3000).Save("browniantree.png");
        }
    }
}
Task: Brownian tree







Python: SIDESTICK = False

def setup() :
    global is_taken
    size(512, 512)
    background(0)
    is_taken = [[False] * height for _ in range(width)]
    is_taken[width/2][height/2] = True


def draw() :
    x = floor(random(width))
    y = floor(random(height))
    if is_taken[x][y]: 
        return
    while True:
        xp = x + floor(random(-1, 2))
        yp = y + floor(random(-1, 2))
        is_contained = 0 <= xp < width and 0 <= yp < height
        if is_contained and not is_taken[xp][yp]:
            x = xp
            y = yp
            continue
        else:
            if SIDESTICK or (is_contained and is_taken[xp][yp]):
                is_taken[x][y] = True
                set(x, y, color(255))            
            break
        
    if frameCount > width * height:
        noLoop()




Fortran: program BrownianTree
  use RCImageBasic
  use RCImageIO

  implicit none

  integer, parameter :: num_particles = 1000
  integer, parameter :: wsize         = 800

  integer, dimension(wsize, wsize) :: world
  type(rgbimage) :: gworld
  integer :: x, y

  
  call init_random_seed
  
  world = 0
  call draw_brownian_tree(world)

  call alloc_img(gworld, wsize, wsize)
  call fill_img(gworld, rgb(0,0,0))
  
  do y = 1, wsize
     do x = 1, wsize
        if ( world(x, y) /= 0 ) then
           call put_pixel(gworld, x, y, rgb(255, 255, 255))
        end if
     end do
  end do

  open(unit=10, file='browniantree.ppm', action='write')
  call output_ppm(10, gworld)
  close(10)

  call free_img(gworld)

contains

  
  subroutine init_random_seed
    integer :: i, n, clock
    integer, dimension(:), allocatable :: seed

    call random_seed(size = n)
    allocate(seed(n))
    call system_clock(count = clock)
    seed = clock + 37 * (/ ( i - 1, i = 1, n) /)
    call random_seed(put = seed)
    deallocate(seed)
  end subroutine init_random_seed


  function randbetween(a, b) result(res) 
    integer, intent(in) :: a, b
    integer :: res

    real :: r

    call random_number(r)

    res = a + int((b-a)*r + 0.5)

  end function randbetween

  function bounded(v, ll, ul) result(res)
    integer, intent(in) :: v, ll, ul
    logical res

    res = ( v >= ll ) .and. ( v <= ul )
  end function bounded


  subroutine draw_brownian_tree(w)
    integer, dimension(:,:), intent(inout) :: w

    integer :: px, py, dx, dy, i
    integer :: xsize, ysize

    xsize = size(w, 1)
    ysize = size(w, 2)

    w(randbetween(1, xsize), randbetween(1, ysize)) = 1
    
    do i = 1, num_particles
       px = randbetween(1, xsize)
       py = randbetween(1, ysize)
       
       do
          dx = randbetween(-1, 1)
          dy = randbetween(-1, 1)
          if ( .not. bounded(dx+px, 1, xsize) .or. .not. bounded(dy+py, 1, ysize) ) then
             px = randbetween(1, xsize)
             py = randbetween(1, ysize)
          else if ( w(px+dx, py+dy) /= 0 ) then
             w(px, py) = 1
             exit
          else
             py = py + dy
             px = px + dx
          end if
       end do
    end do
    
  end subroutine draw_brownian_tree

end program
Task: Guess the number_With feedback (player)

C: #include <stdio.h>

int main(){
  int bounds[ 2 ] = {1, 100};
  char input[ 2 ] = "  ";
    
  int choice = (bounds[ 0 ] + bounds[ 1 ]) / 2;
    

  printf( "Choose a number between %d and %d.\n", bounds[ 0 ], bounds[ 1 ] );

  do{
    switch( input[ 0 ] ){
      case 'H':
        bounds[ 1 ] = choice;
        break;
      case 'L':
        bounds[ 0 ] = choice;
        break;
      case 'Y':
        printf( "\nAwwwright\n" );
        return 0;
    }
    choice = (bounds[ 0 ] + bounds[ 1 ]) / 2;

    printf( "Is the number %d? (Y/H/L) ", choice );
  }while( scanf( "%1s", input ) == 1 );

  return 0;
}











Ada: with Ada.Text_IO;
procedure Guess_Number_Player is
   procedure Guess_Number (Lower_Limit : Integer; Upper_Limit : Integer) is
      type Feedback is (Lower, Higher, Correct);
      package Feedback_IO is new Ada.Text_IO.Enumeration_IO (Feedback);
      My_Guess : Integer := Lower_Limit + (Upper_Limit - Lower_Limit) / 2;
      Your_Feedback : Feedback;
   begin
      Ada.Text_IO.Put_Line ("Think of a number!");
      loop
         Ada.Text_IO.Put_Line ("My guess: " & Integer'Image (My_Guess));
         Ada.Text_IO.Put ("Your answer (lower, higher, correct): ");
         Feedback_IO.Get (Your_Feedback);
         exit when Your_Feedback = Correct;
         if Your_Feedback = Lower then
            My_Guess := Lower_Limit + (My_Guess - Lower_Limit) / 2;
         else
            My_Guess := My_Guess + (Upper_Limit - My_Guess) / 2;
         end if;
      end loop;
      Ada.Text_IO.Put_Line ("I guessed well!");
   end Guess_Number;
   package Int_IO is new Ada.Text_IO.Integer_IO (Integer);
   Lower_Limit : Integer;
   Upper_Limit : Integer;
begin
   loop
      Ada.Text_IO.Put ("Lower Limit: ");
      Int_IO.Get (Lower_Limit);
      Ada.Text_IO.Put ("Upper Limit: ");
      Int_IO.Get (Upper_Limit);
      exit when Lower_Limit < Upper_Limit;
      Ada.Text_IO.Put_Line ("Lower limit must be lower!");
   end loop;
   Guess_Number (Lower_Limit, Upper_Limit);
end Guess_Number_Player;
Task: Guess the number_With feedback (player)




Go: package main

import (
    "fmt"
    "sort"
)

func main() {
    lower, upper := 0, 100
    fmt.Printf(`Instructions:
Think of integer number from %d (inclusive) to %d (exclusive) and
I will guess it. After each guess, I will ask you if it is less than
or equal to some number, and you will respond with "yes" or "no".
`, lower, upper)
    answer := sort.Search(upper-lower, func (i int) bool {
        fmt.Printf("Is your number less than or equal to %d? ", lower+i)
        s := ""
        fmt.Scanf("%s", &s)
        return s != "" && s[0] == 'y'
    })
    fmt.Printf("Your number is %d.\n", lower+answer)
}








Ada: with Ada.Text_IO;
procedure Guess_Number_Player is
   procedure Guess_Number (Lower_Limit : Integer; Upper_Limit : Integer) is
      type Feedback is (Lower, Higher, Correct);
      package Feedback_IO is new Ada.Text_IO.Enumeration_IO (Feedback);
      My_Guess : Integer := Lower_Limit + (Upper_Limit - Lower_Limit) / 2;
      Your_Feedback : Feedback;
   begin
      Ada.Text_IO.Put_Line ("Think of a number!");
      loop
         Ada.Text_IO.Put_Line ("My guess: " & Integer'Image (My_Guess));
         Ada.Text_IO.Put ("Your answer (lower, higher, correct): ");
         Feedback_IO.Get (Your_Feedback);
         exit when Your_Feedback = Correct;
         if Your_Feedback = Lower then
            My_Guess := Lower_Limit + (My_Guess - Lower_Limit) / 2;
         else
            My_Guess := My_Guess + (Upper_Limit - My_Guess) / 2;
         end if;
      end loop;
      Ada.Text_IO.Put_Line ("I guessed well!");
   end Guess_Number;
   package Int_IO is new Ada.Text_IO.Integer_IO (Integer);
   Lower_Limit : Integer;
   Upper_Limit : Integer;
begin
   loop
      Ada.Text_IO.Put ("Lower Limit: ");
      Int_IO.Get (Lower_Limit);
      Ada.Text_IO.Put ("Upper Limit: ");
      Int_IO.Get (Upper_Limit);
      exit when Lower_Limit < Upper_Limit;
      Ada.Text_IO.Put_Line ("Lower limit must be lower!");
   end loop;
   Guess_Number (Lower_Limit, Upper_Limit);
end Guess_Number_Player;
Task: Guess the number_With feedback (player)





Java: import java.util.AbstractList;
import java.util.Collections;
import java.util.Scanner;

public class GuessNumber {
    public static final int LOWER = 0, UPPER = 100;
    public static void main(String[] args) {
	System.out.printf("Instructions:\n" +
			  "Think of integer number from %d (inclusive) to %d (exclusive) and\n" +
			  "I will guess it. After each guess, you respond with L, H, or C depending\n" +
			  "on if my guess was too low, too high, or correct.\n",
			  LOWER, UPPER);
	int result = Collections.binarySearch(new AbstractList<Integer>() {
		private final Scanner in = new Scanner(System.in);
		public int size() { return UPPER - LOWER; }
		public Integer get(int i) {
		    System.out.printf("My guess is: %d. Is it too high, too low, or correct? (H/L/C) ", LOWER+i);
		    String s = in.nextLine();
		    assert s.length() > 0;
		    switch (Character.toLowerCase(s.charAt(0))) {
		    case 'l':
			return -1;
		    case 'h':
			return 1;
		    case 'c':
			return 0;
		    }
		    return -1;
		}
	    }, 0);
	if (result < 0)
	    System.out.println("That is impossible.");
	else
	    System.out.printf("Your number is %d.\n", result);
    }
}







Ada: with Ada.Text_IO;
procedure Guess_Number_Player is
   procedure Guess_Number (Lower_Limit : Integer; Upper_Limit : Integer) is
      type Feedback is (Lower, Higher, Correct);
      package Feedback_IO is new Ada.Text_IO.Enumeration_IO (Feedback);
      My_Guess : Integer := Lower_Limit + (Upper_Limit - Lower_Limit) / 2;
      Your_Feedback : Feedback;
   begin
      Ada.Text_IO.Put_Line ("Think of a number!");
      loop
         Ada.Text_IO.Put_Line ("My guess: " & Integer'Image (My_Guess));
         Ada.Text_IO.Put ("Your answer (lower, higher, correct): ");
         Feedback_IO.Get (Your_Feedback);
         exit when Your_Feedback = Correct;
         if Your_Feedback = Lower then
            My_Guess := Lower_Limit + (My_Guess - Lower_Limit) / 2;
         else
            My_Guess := My_Guess + (Upper_Limit - My_Guess) / 2;
         end if;
      end loop;
      Ada.Text_IO.Put_Line ("I guessed well!");
   end Guess_Number;
   package Int_IO is new Ada.Text_IO.Integer_IO (Integer);
   Lower_Limit : Integer;
   Upper_Limit : Integer;
begin
   loop
      Ada.Text_IO.Put ("Lower Limit: ");
      Int_IO.Get (Lower_Limit);
      Ada.Text_IO.Put ("Upper Limit: ");
      Int_IO.Get (Upper_Limit);
      exit when Lower_Limit < Upper_Limit;
      Ada.Text_IO.Put_Line ("Lower limit must be lower!");
   end loop;
   Guess_Number (Lower_Limit, Upper_Limit);
end Guess_Number_Player;