WeixiangYan/CodeTransOcean huggingface dataset:
Task: Anti-primes



C#: using System;
using System.Linq;
using System.Collections.Generic;
					
public static class Program
{
    public static void Main() =>
        Console.WriteLine(string.Join(" ", FindAntiPrimes().Take(20)));
	
    static IEnumerable<int> FindAntiPrimes() {
        int max = 0;
        for (int i = 1; ; i++) {
            int divisors = CountDivisors(i);
            if (divisors > max) {
                max = divisors;
                yield return i;
            }
        }
	
        int CountDivisors(int n) => Enumerable.Range(1, n / 2).Count(i => n % i == 0) + 1;
    }
}
Task: Anti-primes


C++: #include <iostream>

int countDivisors(int n) {
    if (n < 2) return 1;
    int count = 2; 
    for (int i = 2; i <= n/2; ++i) {
        if (n%i == 0) ++count;
    }
    return count;
}

int main() {
    int maxDiv = 0, count = 0;
    std::cout << "The first 20 anti-primes are:" << std::endl;
    for (int n = 1; count < 20; ++n) {
        int d = countDivisors(n);
        if (d > maxDiv) {
            std::cout << n << " ";
            maxDiv = d;
            count++;
        }
    }
    std::cout << std::endl;
    return 0;
}
Task: Anti-primes





Java: public class Antiprime {

    static int countDivisors(int n) {
        if (n < 2) return 1;
        int count = 2; 
        for (int i = 2; i <= n/2; ++i) {
            if (n%i == 0) ++count;
        }
        return count;
    }

    public static void main(String[] args) {
        int maxDiv = 0, count = 0;
        System.out.println("The first 20 anti-primes are:");
        for (int n = 1; count < 20; ++n) {
            int d = countDivisors(n);
            if (d > maxDiv) {
                System.out.printf("%d ", n);
                maxDiv = d;
                count++;
            }
        }
        System.out.println();
    }
}
Task: Anti-primes







Python: from itertools import chain, count, cycle, islice, accumulate
 
def factors(n):
    def prime_powers(n):
        for c in accumulate(chain([2, 1, 2], cycle([2,4]))):
            if c*c > n: break
            if n%c: continue
            d,p = (), c
            while not n%c:
                n,p,d = n//c, p*c, d+(p,)
            yield d
        if n > 1: yield n,
 
    r = [1]
    for e in prime_powers(n):
        r += [a*b for a in r for b in e]
    return r
    
def antiprimes():
    mx = 0
    yield 1
    for c in count(2,2):
        if c >= 58: break
        ln = len(factors(c))
        if ln > mx:
            yield c
            mx = ln
    for c in count(60,30):
        ln = len(factors(c))
        if ln > mx:
            yield c
            mx = ln  

if __name__ == '__main__':
    print(*islice(antiprimes(), 40)))
Task: Anti-primes








VB: Dim Results(20)
Candidate = 1
max_divisors = 0

Print "Los primeros 20 anti-primos son:"
For j = 0 To 19
	Do
		divisors = count_divisors(Candidate)
		If max_divisors < divisors Then
			Results[j] = Candidate
			max_divisors = divisors
			Exit Do
		End If
		Candidate += 1
	Until false
	Print Results[j];" ";
Next j

Function count_divisors(n)
	cont = 1
	For i = 1 To n/2
		If (n % i) = 0 Then cont += 1
	Next i
	count_divisors = cont
End Function
Task: Anti-primes




Go: package main

import "fmt"

func countDivisors(n int) int {
    if n < 2 {
        return 1
    }
    count := 2 
    for i := 2; i <= n/2; i++ {
        if n%i == 0 {
            count++
        }
    }
    return count
}

func main() {
    fmt.Println("The first 20 anti-primes are:")
    maxDiv := 0
    count := 0
    for n := 1; count < 20; n++ {
        d := countDivisors(n)
        if d > maxDiv {
            fmt.Printf("%d ", n)
            maxDiv = d
            count++
        }
    }
    fmt.Println()
}
Task: Anti-primes



C#: using System;
using System.Linq;
using System.Collections.Generic;
					
public static class Program
{
    public static void Main() =>
        Console.WriteLine(string.Join(" ", FindAntiPrimes().Take(20)));
	
    static IEnumerable<int> FindAntiPrimes() {
        int max = 0;
        for (int i = 1; ; i++) {
            int divisors = CountDivisors(i);
            if (divisors > max) {
                max = divisors;
                yield return i;
            }
        }
	
        int CountDivisors(int n) => Enumerable.Range(1, n / 2).Count(i => n % i == 0) + 1;
    }
}








Fortran: program anti_primes
    use iso_fortran_env, only: output_unit
    implicit none

    integer :: n, d, maxDiv, pCount

    write(output_unit,*) "The first 20 anti-primes are:"
    n = 1
    maxDiv = 0
    pCount = 0
    do
        if (pCount >= 20) exit

        d = countDivisors(n)
        if (d > maxDiv) then
            write(output_unit,'(I0,x)', advance="no") n
            maxDiv = d
            pCount = pCount + 1
        end if
        n = n + 1
    end do
    write(output_unit,*)
contains
    pure function countDivisors(n)
        integer, intent(in) :: n
        integer             :: countDivisors
        integer             :: i

        countDivisors = 1
        if (n < 2) return
        countDivisors = 2
        do i = 2, n/2
            if (modulo(n, i) == 0) countDivisors = countDivisors + 1
        end do
    end function countDivisors
end program anti_primes
Task: Anti-primes


C++: #include <iostream>

int countDivisors(int n) {
    if (n < 2) return 1;
    int count = 2; 
    for (int i = 2; i <= n/2; ++i) {
        if (n%i == 0) ++count;
    }
    return count;
}

int main() {
    int maxDiv = 0, count = 0;
    std::cout << "The first 20 anti-primes are:" << std::endl;
    for (int n = 1; count < 20; ++n) {
        int d = countDivisors(n);
        if (d > maxDiv) {
            std::cout << n << " ";
            maxDiv = d;
            count++;
        }
    }
    std::cout << std::endl;
    return 0;
}









Fortran: program anti_primes
    use iso_fortran_env, only: output_unit
    implicit none

    integer :: n, d, maxDiv, pCount

    write(output_unit,*) "The first 20 anti-primes are:"
    n = 1
    maxDiv = 0
    pCount = 0
    do
        if (pCount >= 20) exit

        d = countDivisors(n)
        if (d > maxDiv) then
            write(output_unit,'(I0,x)', advance="no") n
            maxDiv = d
            pCount = pCount + 1
        end if
        n = n + 1
    end do
    write(output_unit,*)
contains
    pure function countDivisors(n)
        integer, intent(in) :: n
        integer             :: countDivisors
        integer             :: i

        countDivisors = 1
        if (n < 2) return
        countDivisors = 2
        do i = 2, n/2
            if (modulo(n, i) == 0) countDivisors = countDivisors + 1
        end do
    end function countDivisors
end program anti_primes
Task: Anti-primes

C: #include <stdio.h>

int countDivisors(int n) {
    int i, count;
    if (n < 2) return 1;
    count = 2; 
    for (i = 2; i <= n/2; ++i) {
        if (n%i == 0) ++count;
    }
    return count;
}

int main() {
    int n, d, maxDiv = 0, count = 0;
    printf("The first 20 anti-primes are:\n");
    for (n = 1; count < 20; ++n) {
        d = countDivisors(n); 
        if (d > maxDiv) {
            printf("%d ", n);
            maxDiv = d;
            count++;
        }
    }
    printf("\n"); 
    return 0;
}










Fortran: program anti_primes
    use iso_fortran_env, only: output_unit
    implicit none

    integer :: n, d, maxDiv, pCount

    write(output_unit,*) "The first 20 anti-primes are:"
    n = 1
    maxDiv = 0
    pCount = 0
    do
        if (pCount >= 20) exit

        d = countDivisors(n)
        if (d > maxDiv) then
            write(output_unit,'(I0,x)', advance="no") n
            maxDiv = d
            pCount = pCount + 1
        end if
        n = n + 1
    end do
    write(output_unit,*)
contains
    pure function countDivisors(n)
        integer, intent(in) :: n
        integer             :: countDivisors
        integer             :: i

        countDivisors = 1
        if (n < 2) return
        countDivisors = 2
        do i = 2, n/2
            if (modulo(n, i) == 0) countDivisors = countDivisors + 1
        end do
    end function countDivisors
end program anti_primes
Task: Anti-primes




Go: package main

import "fmt"

func countDivisors(n int) int {
    if n < 2 {
        return 1
    }
    count := 2 
    for i := 2; i <= n/2; i++ {
        if n%i == 0 {
            count++
        }
    }
    return count
}

func main() {
    fmt.Println("The first 20 anti-primes are:")
    maxDiv := 0
    count := 0
    for n := 1; count < 20; n++ {
        d := countDivisors(n)
        if d > maxDiv {
            fmt.Printf("%d ", n)
            maxDiv = d
            count++
        }
    }
    fmt.Println()
}







Fortran: program anti_primes
    use iso_fortran_env, only: output_unit
    implicit none

    integer :: n, d, maxDiv, pCount

    write(output_unit,*) "The first 20 anti-primes are:"
    n = 1
    maxDiv = 0
    pCount = 0
    do
        if (pCount >= 20) exit

        d = countDivisors(n)
        if (d > maxDiv) then
            write(output_unit,'(I0,x)', advance="no") n
            maxDiv = d
            pCount = pCount + 1
        end if
        n = n + 1
    end do
    write(output_unit,*)
contains
    pure function countDivisors(n)
        integer, intent(in) :: n
        integer             :: countDivisors
        integer             :: i

        countDivisors = 1
        if (n < 2) return
        countDivisors = 2
        do i = 2, n/2
            if (modulo(n, i) == 0) countDivisors = countDivisors + 1
        end do
    end function countDivisors
end program anti_primes
Task: Anti-primes





Java: public class Antiprime {

    static int countDivisors(int n) {
        if (n < 2) return 1;
        int count = 2; 
        for (int i = 2; i <= n/2; ++i) {
            if (n%i == 0) ++count;
        }
        return count;
    }

    public static void main(String[] args) {
        int maxDiv = 0, count = 0;
        System.out.println("The first 20 anti-primes are:");
        for (int n = 1; count < 20; ++n) {
            int d = countDivisors(n);
            if (d > maxDiv) {
                System.out.printf("%d ", n);
                maxDiv = d;
                count++;
            }
        }
        System.out.println();
    }
}






Fortran: program anti_primes
    use iso_fortran_env, only: output_unit
    implicit none

    integer :: n, d, maxDiv, pCount

    write(output_unit,*) "The first 20 anti-primes are:"
    n = 1
    maxDiv = 0
    pCount = 0
    do
        if (pCount >= 20) exit

        d = countDivisors(n)
        if (d > maxDiv) then
            write(output_unit,'(I0,x)', advance="no") n
            maxDiv = d
            pCount = pCount + 1
        end if
        n = n + 1
    end do
    write(output_unit,*)
contains
    pure function countDivisors(n)
        integer, intent(in) :: n
        integer             :: countDivisors
        integer             :: i

        countDivisors = 1
        if (n < 2) return
        countDivisors = 2
        do i = 2, n/2
            if (modulo(n, i) == 0) countDivisors = countDivisors + 1
        end do
    end function countDivisors
end program anti_primes
Task: Anti-primes







Python: from itertools import chain, count, cycle, islice, accumulate
 
def factors(n):
    def prime_powers(n):
        for c in accumulate(chain([2, 1, 2], cycle([2,4]))):
            if c*c > n: break
            if n%c: continue
            d,p = (), c
            while not n%c:
                n,p,d = n//c, p*c, d+(p,)
            yield d
        if n > 1: yield n,
 
    r = [1]
    for e in prime_powers(n):
        r += [a*b for a in r for b in e]
    return r
    
def antiprimes():
    mx = 0
    yield 1
    for c in count(2,2):
        if c >= 58: break
        ln = len(factors(c))
        if ln > mx:
            yield c
            mx = ln
    for c in count(60,30):
        ln = len(factors(c))
        if ln > mx:
            yield c
            mx = ln  

if __name__ == '__main__':
    print(*islice(antiprimes(), 40)))




Fortran: program anti_primes
    use iso_fortran_env, only: output_unit
    implicit none

    integer :: n, d, maxDiv, pCount

    write(output_unit,*) "The first 20 anti-primes are:"
    n = 1
    maxDiv = 0
    pCount = 0
    do
        if (pCount >= 20) exit

        d = countDivisors(n)
        if (d > maxDiv) then
            write(output_unit,'(I0,x)', advance="no") n
            maxDiv = d
            pCount = pCount + 1
        end if
        n = n + 1
    end do
    write(output_unit,*)
contains
    pure function countDivisors(n)
        integer, intent(in) :: n
        integer             :: countDivisors
        integer             :: i

        countDivisors = 1
        if (n < 2) return
        countDivisors = 2
        do i = 2, n/2
            if (modulo(n, i) == 0) countDivisors = countDivisors + 1
        end do
    end function countDivisors
end program anti_primes
Task: Anti-primes








VB: Dim Results(20)
Candidate = 1
max_divisors = 0

Print "Los primeros 20 anti-primos son:"
For j = 0 To 19
	Do
		divisors = count_divisors(Candidate)
		If max_divisors < divisors Then
			Results[j] = Candidate
			max_divisors = divisors
			Exit Do
		End If
		Candidate += 1
	Until false
	Print Results[j];" ";
Next j

Function count_divisors(n)
	cont = 1
	For i = 1 To n/2
		If (n % i) = 0 Then cont += 1
	Next i
	count_divisors = cont
End Function



Fortran: program anti_primes
    use iso_fortran_env, only: output_unit
    implicit none

    integer :: n, d, maxDiv, pCount

    write(output_unit,*) "The first 20 anti-primes are:"
    n = 1
    maxDiv = 0
    pCount = 0
    do
        if (pCount >= 20) exit

        d = countDivisors(n)
        if (d > maxDiv) then
            write(output_unit,'(I0,x)', advance="no") n
            maxDiv = d
            pCount = pCount + 1
        end if
        n = n + 1
    end do
    write(output_unit,*)
contains
    pure function countDivisors(n)
        integer, intent(in) :: n
        integer             :: countDivisors
        integer             :: i

        countDivisors = 1
        if (n < 2) return
        countDivisors = 2
        do i = 2, n/2
            if (modulo(n, i) == 0) countDivisors = countDivisors + 1
        end do
    end function countDivisors
end program anti_primes
Task: Anti-primes








VB: Private Function factors(n As Integer) As Collection
    Dim f As New Collection
    For i = 1 To Sqr(n)
        If n Mod i = 0 Then
            f.Add i
            If n / i <> i Then f.Add n / i
        End If
    Next i
    f.Add n
    Set factors = f
End Function
Public Sub anti_primes()
    Dim n As Integer, maxd As Integer
    Dim res As New Collection, lenght As Integer
    Dim lf As Integer
    n = 1: maxd = -1
    Length = 0
    Do While res.count < 20
        lf = factors(n).count
        If lf > maxd Then
            res.Add n
            maxd = lf
        End If
        n = n + IIf(n > 1, 2, 1)
    Loop
    Debug.Print "The first 20 anti-primes are:";
    For Each x In res
        Debug.Print x;
    Next x
End Sub
Task: Bitmap_Bresenham's line algorithm



C#: using System;
using System.Drawing;
using System.Drawing.Imaging;
static class Program
{
    static void Main()
    {
        new Bitmap(200, 200)
            .DrawLine(0, 0, 199, 199, Color.Black).DrawLine(199,0,0,199,Color.Black)
            .DrawLine(50, 75, 150, 125, Color.Blue).DrawLine(150, 75, 50, 125, Color.Blue)
            .Save("line.png", ImageFormat.Png);
    }
    static Bitmap DrawLine(this Bitmap bitmap, int x0, int y0, int x1, int y1, Color color)
    {
        int dx = Math.Abs(x1 - x0), sx = x0 < x1 ? 1 : -1;
        int dy = Math.Abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
        int err = (dx > dy ? dx : -dy) / 2, e2;
        for(;;) {
            bitmap.SetPixel(x0, y0, color);
            if (x0 == x1 && y0 == y1) break;
            e2 = err;
            if (e2 > -dx) { err -= dy; x0 += sx; }
            if (e2 < dy) { err += dx; y0 += sy; }
        }
        return bitmap;
    }
}









Ada: procedure Line (Picture : in out Image; Start, Stop : Point; Color : Pixel) is
   DX  : constant Float := abs Float (Stop.X - Start.X);
   DY  : constant Float := abs Float (Stop.Y - Start.Y);
   Err : Float;
   X   : Positive := Start.X;
   Y   : Positive := Start.Y;
   Step_X : Integer := 1;
   Step_Y : Integer := 1;
begin
   if Start.X > Stop.X then
      Step_X := -1;
   end if;
   if Start.Y > Stop.Y then
      Step_Y := -1;
   end if;
   if DX > DY then
      Err := DX / 2.0;
      while X /= Stop.X loop
         Picture (X, Y) := Color;
         Err := Err - DY;
         if Err < 0.0 then
            Y := Y + Step_Y;
            Err := Err + DX;
         end if;
         X := X + Step_X;
      end loop;
   else
      Err := DY / 2.0;
      while Y /= Stop.Y loop
         Picture (X, Y) := Color;
         Err := Err - DX;
         if Err < 0.0 then
            X := X + Step_X;
            Err := Err + DY;
         end if;
         Y := Y + Step_Y;
      end loop;
   end if;
   Picture (X, Y) := Color; 
end Line;
Task: Bitmap_Bresenham's line algorithm

C: void line(int x0, int y0, int x1, int y1) {

  int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1;
  int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1; 
  int err = (dx>dy ? dx : -dy)/2, e2;

  for(;;){
    setPixel(x0,y0);
    if (x0==x1 && y0==y1) break;
    e2 = err;
    if (e2 >-dx) { err -= dy; x0 += sx; }
    if (e2 < dy) { err += dx; y0 += sy; }
  }
}











Ada: procedure Line (Picture : in out Image; Start, Stop : Point; Color : Pixel) is
   DX  : constant Float := abs Float (Stop.X - Start.X);
   DY  : constant Float := abs Float (Stop.Y - Start.Y);
   Err : Float;
   X   : Positive := Start.X;
   Y   : Positive := Start.Y;
   Step_X : Integer := 1;
   Step_Y : Integer := 1;
begin
   if Start.X > Stop.X then
      Step_X := -1;
   end if;
   if Start.Y > Stop.Y then
      Step_Y := -1;
   end if;
   if DX > DY then
      Err := DX / 2.0;
      while X /= Stop.X loop
         Picture (X, Y) := Color;
         Err := Err - DY;
         if Err < 0.0 then
            Y := Y + Step_Y;
            Err := Err + DX;
         end if;
         X := X + Step_X;
      end loop;
   else
      Err := DY / 2.0;
      while Y /= Stop.Y loop
         Picture (X, Y) := Color;
         Err := Err - DX;
         if Err < 0.0 then
            X := X + Step_X;
            Err := Err + DY;
         end if;
         Y := Y + Step_Y;
      end loop;
   end if;
   Picture (X, Y) := Color; 
end Line;
Task: Bitmap_Bresenham's line algorithm


C++: void Line( float x1, float y1, float x2, float y2, const Color& color )
{
        
  const bool steep = (fabs(y2 - y1) > fabs(x2 - x1));
  if(steep)
  {
    std::swap(x1, y1);
    std::swap(x2, y2);
  }

  if(x1 > x2)
  {
    std::swap(x1, x2);
    std::swap(y1, y2);
  }

  const float dx = x2 - x1;
  const float dy = fabs(y2 - y1);
  
  float error = dx / 2.0f;
  const int ystep = (y1 < y2) ? 1 : -1;
  int y = (int)y1;

  const int maxX = (int)x2;

  for(int x=(int)x1; x<=maxX; x++)
  {
    if(steep)
    {
        SetPixel(y,x, color);
    }
    else
    {
        SetPixel(x,y, color);
    }
              
    error -= dy;
    if(error < 0)
    {
        y += ystep;
        error += dx;
    }
  }
}










Ada: procedure Line (Picture : in out Image; Start, Stop : Point; Color : Pixel) is
   DX  : constant Float := abs Float (Stop.X - Start.X);
   DY  : constant Float := abs Float (Stop.Y - Start.Y);
   Err : Float;
   X   : Positive := Start.X;
   Y   : Positive := Start.Y;
   Step_X : Integer := 1;
   Step_Y : Integer := 1;
begin
   if Start.X > Stop.X then
      Step_X := -1;
   end if;
   if Start.Y > Stop.Y then
      Step_Y := -1;
   end if;
   if DX > DY then
      Err := DX / 2.0;
      while X /= Stop.X loop
         Picture (X, Y) := Color;
         Err := Err - DY;
         if Err < 0.0 then
            Y := Y + Step_Y;
            Err := Err + DX;
         end if;
         X := X + Step_X;
      end loop;
   else
      Err := DY / 2.0;
      while Y /= Stop.Y loop
         Picture (X, Y) := Color;
         Err := Err - DX;
         if Err < 0.0 then
            X := X + Step_X;
            Err := Err + DY;
         end if;
         Y := Y + Step_Y;
      end loop;
   end if;
   Picture (X, Y) := Color; 
end Line;
Task: Bitmap_Bresenham's line algorithm




Go: package raster


func (b *Bitmap) Line(x0, y0, x1, y1 int, p Pixel) {
    
    dx := x1 - x0
    if dx < 0 {
        dx = -dx
    }
    dy := y1 - y0
    if dy < 0 {
        dy = -dy
    }
    var sx, sy int
    if x0 < x1 {
        sx = 1
    } else {
        sx = -1
    }
    if y0 < y1 {
        sy = 1
    } else {
        sy = -1
    }
    err := dx - dy

    for {
        b.SetPx(x0, y0, p)
        if x0 == x1 && y0 == y1 {
            break
        }
        e2 := 2 * err
        if e2 > -dy {
            err -= dy
            x0 += sx
        }
        if e2 < dx {
            err += dx
            y0 += sy
        }
    }
}

func (b *Bitmap) LineRgb(x0, y0, x1, y1 int, c Rgb) {
    b.Line(x0, y0, x1, y1, c.Pixel())
}








Ada: procedure Line (Picture : in out Image; Start, Stop : Point; Color : Pixel) is
   DX  : constant Float := abs Float (Stop.X - Start.X);
   DY  : constant Float := abs Float (Stop.Y - Start.Y);
   Err : Float;
   X   : Positive := Start.X;
   Y   : Positive := Start.Y;
   Step_X : Integer := 1;
   Step_Y : Integer := 1;
begin
   if Start.X > Stop.X then
      Step_X := -1;
   end if;
   if Start.Y > Stop.Y then
      Step_Y := -1;
   end if;
   if DX > DY then
      Err := DX / 2.0;
      while X /= Stop.X loop
         Picture (X, Y) := Color;
         Err := Err - DY;
         if Err < 0.0 then
            Y := Y + Step_Y;
            Err := Err + DX;
         end if;
         X := X + Step_X;
      end loop;
   else
      Err := DY / 2.0;
      while Y /= Stop.Y loop
         Picture (X, Y) := Color;
         Err := Err - DX;
         if Err < 0.0 then
            X := X + Step_X;
            Err := Err + DY;
         end if;
         Y := Y + Step_Y;
      end loop;
   end if;
   Picture (X, Y) := Color; 
end Line;
Task: Bitmap_Bresenham's line algorithm







Python: def line(self, x0, y0, x1, y1):
    "Bresenham's line algorithm"
    dx = abs(x1 - x0)
    dy = abs(y1 - y0)
    x, y = x0, y0
    sx = -1 if x0 > x1 else 1
    sy = -1 if y0 > y1 else 1
    if dx > dy:
        err = dx / 2.0
        while x != x1:
            self.set(x, y)
            err -= dy
            if err < 0:
                y += sy
                err += dx
            x += sx
    else:
        err = dy / 2.0
        while y != y1:
            self.set(x, y)
            err -= dx
            if err < 0:
                x += sx
                err += dy
            y += sy        
    self.set(x, y)
Bitmap.line = line

bitmap = Bitmap(17,17)
for points in ((1,8,8,16),(8,16,16,8),(16,8,8,1),(8,1,1,8)):
    bitmap.line(*points)
bitmap.chardisplay()







Ada: procedure Line (Picture : in out Image; Start, Stop : Point; Color : Pixel) is
   DX  : constant Float := abs Float (Stop.X - Start.X);
   DY  : constant Float := abs Float (Stop.Y - Start.Y);
   Err : Float;
   X   : Positive := Start.X;
   Y   : Positive := Start.Y;
   Step_X : Integer := 1;
   Step_Y : Integer := 1;
begin
   if Start.X > Stop.X then
      Step_X := -1;
   end if;
   if Start.Y > Stop.Y then
      Step_Y := -1;
   end if;
   if DX > DY then
      Err := DX / 2.0;
      while X /= Stop.X loop
         Picture (X, Y) := Color;
         Err := Err - DY;
         if Err < 0.0 then
            Y := Y + Step_Y;
            Err := Err + DX;
         end if;
         X := X + Step_X;
      end loop;
   else
      Err := DY / 2.0;
      while Y /= Stop.Y loop
         Picture (X, Y) := Color;
         Err := Err - DX;
         if Err < 0.0 then
            X := X + Step_X;
            Err := Err + DY;
         end if;
         Y := Y + Step_Y;
      end loop;
   end if;
   Picture (X, Y) := Color; 
end Line;