WeixiangYan/CodeTransOcean huggingface dataset:
Task: Bitmap_Flood fill







Python: from collections import deque

image_file = "image.png"
fill_color = color(250, 0, 0)
tolerance = 15
allowed = False

def setup():
    global img
    size(600, 400)
    img = loadImage(image_file)
    fill(0, 0, 100)
    textSize(18)
    show()
    
def show():
    image(img, 0, 0, width, height)
    text("Tolerance = {}    (Use mouse wheel to change)".format(tolerance),
         100, height - 30)
    text("Right click to reset", 100, height - 10)
 
def draw():
    global allowed
    if allowed:
        show()
        allowed = False

def mousePressed():
    global allowed, img
    if mouseButton == RIGHT:
        img = loadImage(image_file)
    else:
        img.loadPixels()
        flood(mouseX, mouseY)
        img.updatePixels()
    allowed = True    

def mouseWheel(event):
    global allowed, tolerance
    e = event.getCount()
    tolerance += 2 * e
    if tolerance > 128:
        tolerance = 128
    if tolerance < 0:
        tolerance = 0
    allowed = True

def flood(x, y):
    target_color = img.pixels[pixel_position(mouseX, mouseY)]
    if target_color != fill_color:
        queue = deque()
        queue.append((x, y))
        while len(queue) > 0:
            p_x, p_y = queue.popleft()
            if (check(p_x, p_y, target_color)):
                queue.append((p_x, p_y - 1))
                queue.append((p_x, p_y + 1))
                queue.append((p_x - 1, p_y))
                queue.append((p_x + 1, p_y))

def pixel_position(x, y):
    return x + (y * img.width)

def check(x, y, target_color):
    if x < 0 or y < 0 or y >= img.height or x >= img.width:
        return False
    pp = img.pixels[pixel_position(x, y)]
    test_tolerance = (abs(green(target_color) - green(pp)) < tolerance
                      and abs(red(target_color) - red(pp)) < tolerance
                      and abs(blue(target_color) - blue(pp)) < tolerance)
    if not test_tolerance:
        return False
    img.pixels[pixel_position(x, y)] = fill_color
    return True
Task: Bitmap_Flood fill




Go: package raster

func (b *Bitmap) Flood(x, y int, repl Pixel) {
    targ, _ := b.GetPx(x, y)
    var ff func(x, y int)
    ff = func(x, y int) {
        p, ok := b.GetPx(x, y)
        if ok && p.R == targ.R && p.G == targ.G && p.B == targ.B {
            b.SetPx(x, y, repl)
            ff(x-1, y)
            ff(x+1, y)
            ff(x, y-1)
            ff(x, y+1)
        }
    }
    ff(x, y)
}
Task: Dutch national flag problem

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

#define NUMBALLS 5 

int compar(const void *a, const void *b){
	char c1=*(const char*)a, c2=*(const char*)b; 
	return c1-c2;
}

_Bool issorted(char *balls){
	int i,state;
	state=0;
	for(i=0;i<NUMBALLS;i++){
		if(balls[i]<state)return false;
		if(balls[i]>state)state=balls[i];
	}
	return true;
}

void printout(char *balls){
	int i;
	char str[NUMBALLS+1];
	for(i=0;i<NUMBALLS;i++)str[i]=balls[i]==0?'r':balls[i]==1?'w':'b';
	printf("%s\n",str);
}

int main(void) {
	char balls[NUMBALLS]; 
	int i;
	srand(time(NULL)); 
	rand(); 
	        
	
	for(i=0;i<NUMBALLS;i++)balls[i]=(double)rand()/RAND_MAX*3;
	while(issorted(balls)){ 
		printf("Accidentally still sorted: ");
		printout(balls);
		for(i=0;i<NUMBALLS;i++)balls[i]=(double)rand()/RAND_MAX*3;
	}
	printf("Non-sorted: ");
	printout(balls);
	qsort(balls,NUMBALLS,sizeof(char),compar); 
	if(issorted(balls)){ 
		printf("Sorted: ");
		printout(balls);
	} else {
		printf("Sort failed: ");
		printout(balls);
	}
	return 0;
}
Task: Dutch national flag problem



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

namespace RosettaCode
{
    class Program
    {
        static void QuickSort(IComparable[] elements, int left, int right)
        {
            int i = left, j = right;
            IComparable pivot = elements[left + (right - left) / 2];

            while (i <= j)
            {
                while (elements[i].CompareTo(pivot) < 0) i++;
                while (elements[j].CompareTo(pivot) > 0) j--;

                if (i <= j)
                {
                    
                    IComparable tmp = elements[i];
                    elements[i] = elements[j];
                    elements[j] = tmp;
                    i++;
                    j--;
                }
            }

            
            if (left < j) QuickSort(elements, left, j);
            if (i < right) QuickSort(elements, i, right);
        }
        const int NUMBALLS = 5;
        static void Main(string[] args)
        {
            Func<string[], bool> IsSorted = (ballList) =>
                {
                    int state = 0;
                    for (int i = 0; i < NUMBALLS; i++)
                    {
                        if (int.Parse(ballList[i]) < state)
                            return false;
                        if (int.Parse(ballList[i]) > state)
                            state = int.Parse(ballList[i]);
                    }
                    return true;
                };
            Func<string[], string> PrintOut = (ballList2) =>
                {
                    StringBuilder str = new StringBuilder();
                    for (int i = 0; i < NUMBALLS; i++)
                        str.Append(int.Parse(ballList2[i]) == 0 ? "r" : int.Parse(ballList2[i]) == 1 ? "w" : "b");
                    return str.ToString();
                };
            bool continueLoop = true;
            string[] balls = new string[NUMBALLS]; 
            Random numberGenerator = new Random();
            do 
            {
                
                for (int i = 0; i < NUMBALLS; i++)
                    balls[i] = numberGenerator.Next(3).ToString();

                continueLoop = IsSorted(balls);
                if (continueLoop)
                    Console.WriteLine("Accidentally still sorted: {0}", PrintOut(balls));
            } while (continueLoop);
            Console.WriteLine("Non-sorted: {0}", PrintOut(balls));
            QuickSort(balls, 0, NUMBALLS - 1); 
            Console.WriteLine("{0}: {1}", IsSorted(balls) ? "Sorted" : "Sort failed", PrintOut(balls));
        }
    }
}
Task: Dutch national flag problem


C++: #include <algorithm>
#include <iostream>


template <typename BidIt, typename T>
void dnf_partition(BidIt first, BidIt last, const T& low, const T& high)
{
    for (BidIt next = first; next != last; ) {
        if (*next < low) {
            std::iter_swap(first++, next++);
        } else if (!(*next < high)) {
            std::iter_swap(next, --last);
        } else {
            ++next;
        }
    }
}

enum Colors { RED, WHITE, BLUE };

void print(const Colors *balls, size_t size)
{
    static const char *label[] = { "red", "white", "blue" };

    std::cout << "Balls:";
    for (size_t i = 0; i < size; ++i) {
        std::cout << ' ' << label[balls[i]];
    }
    std::cout << "\nSorted: " << std::boolalpha << std::is_sorted(balls, balls + size) << '\n';
}

int main()
{
    Colors balls[] = { RED, WHITE, BLUE, RED, WHITE, BLUE, RED, WHITE, BLUE };

    std::random_shuffle(balls, balls + 9);
    print(balls, 9);

    dnf_partition(balls, balls + 9, WHITE, BLUE);
    print(balls, 9);
}
Task: Dutch national flag problem





Java: import java.util.Arrays;
import java.util.Random;

public class DutchNationalFlag {
    enum DutchColors {
        RED, WHITE, BLUE
    }

    public static void main(String[] args){
        DutchColors[] balls = new DutchColors[12];
        DutchColors[] values = DutchColors.values();
        Random rand = new Random();

        for (int i = 0; i < balls.length; i++)
            balls[i]=values[rand.nextInt(values.length)];
        System.out.println("Before: " + Arrays.toString(balls));

        Arrays.sort(balls);
        System.out.println("After:  " + Arrays.toString(balls));

        boolean sorted = true;
        for (int i = 1; i < balls.length; i++ ){
            if (balls[i-1].compareTo(balls[i]) > 0){
                sorted=false;
                break;
            }
        }
        System.out.println("Correctly sorted: " + sorted);
    }
}
Task: Dutch national flag problem







Python: import random

colours_in_order = 'Red White Blue'.split()

def dutch_flag_sort(items, order=colours_in_order):
    'return sort of items using the given order'
    reverse_index = dict((x,i) for i,x in enumerate(order))
    return sorted(items, key=lambda x: reverse_index[x])

def dutch_flag_check(items, order=colours_in_order):
    'Return True if each item of items is in the given order'
    reverse_index = dict((x,i) for i,x in enumerate(order))
    order_of_items = [reverse_index[item] for item in items]
    return all(x <= y for x, y in zip(order_of_items, order_of_items[1:]))

def random_balls(mx=5):
    'Select from 1 to mx balls of each colour, randomly'
    balls = sum([[colour] * random.randint(1, mx)
                 for colour in colours_in_order], [])
    random.shuffle(balls)
    return balls

def main():
    
    while True:
        balls = random_balls()
        if not dutch_flag_check(balls):
            break
    print("Original Ball order:", balls)
    sorted_balls = dutch_flag_sort(balls)
    print("Sorted Ball Order:", sorted_balls)
    assert dutch_flag_check(sorted_balls), 'Whoops. Not sorted!'

if __name__ == '__main__':
    main()
Task: Dutch national flag problem








VB: 


Function build_unsort(n)
	flag = Array("red","white","blue")
	Set random = CreateObject("System.Random")
	Dim arr()
	ReDim arr(n)
	For i = 0 To n
		arr(i) = flag(random.Next_2(0,3))
	Next
	build_unsort = arr
End Function


Function sort(arr)
	lo = 0
	mi = 0
	hi = UBound(arr)
	Do While mi <= hi 
		Select Case arr(mi)
			Case "red"
				tmp = arr(lo)
				arr(lo) = arr(mi)
				arr(mi) = tmp
				lo = lo + 1
				mi = mi + 1
			Case "white"
				mi = mi + 1
			Case "blue"
				tmp = arr(mi)
				arr(mi) = arr(hi)
				arr(hi) = tmp
				hi = hi - 1
		End Select 
	Loop
	sort = Join(arr,",")
End Function

unsort = build_unsort(11)
WScript.StdOut.Write "Unsorted: " & Join(unsort,",")
WScript.StdOut.WriteLine
WScript.StdOut.Write "Sorted: " & sort(unsort)
WScript.StdOut.WriteLine
Task: Dutch national flag problem




Go: package main

import (
    "fmt"
    "math/rand"
    "time"
)


const (
    red = iota
    white
    blue
    nColors
)


type ball struct {
    color int
}


func (b1 ball) lt(b2 ball) bool {
    return b1.color < b2.color
}


type ordering []ball


func (o ordering) ordered() bool {
    var b0 ball
    for _, b := range o {
        if b.lt(b0) {
            return false
        }
        b0 = b
    }
    return true
}

func init() {
    rand.Seed(time.Now().Unix())
}



func outOfOrder(n int) ordering {
    if n < 2 {
        panic(fmt.Sprintf("%d invalid", n))
    }
    r := make(ordering, n)
    for {
        for i, _ := range r {
            r[i].color = rand.Intn(nColors)
        }
        if !r.ordered() {
            break
        }
    }
    return r
}



func (a ordering) sort3() {
    lo, mid, hi := 0, 0, len(a)-1
    for mid <= hi {
        switch a[mid].color {
        case red:
            a[lo], a[mid] = a[mid], a[lo]
            lo++
            mid++
        case white:
            mid++
        default:
            a[mid], a[hi] = a[hi], a[mid]
            hi--
        }
    }
}

func main() {
    f := outOfOrder(12)
    fmt.Println(f)
    f.sort3()
    fmt.Println(f)
}
Task: Determine if a string has all the same characters



C#: using System;

namespace AllSame {
    class Program {
        static void Analyze(string s) {
            Console.WriteLine("Examining [{0}] which has a length of {1}:", s, s.Length);
            if (s.Length > 1) {
                var b = s[0];
                for (int i = 1; i < s.Length; i++) {
                    var c = s[i];
                    if (c != b) {
                        Console.WriteLine("    Not all characters in the string are the same.");
                        Console.WriteLine("    '{0}' (0x{1:X02}) is different at position {2}", c, (int)c, i);
                        return;
                    }
                }

            }
            Console.WriteLine("    All characters in the string are the same.");
        }

        static void Main() {
            var strs = new string[] { "", "   ", "2", "333", ".55", "tttTTT", "4444 444k" };
            foreach (var str in strs) {
                Analyze(str);
            }
        }
    }
}









Ada: with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_All_Chars_Are_Same is
   procedure All_Chars_Are_Same (S : in String) is
      First_Diff : Natural := 0;
   begin
      Put_Line ("Input = """ & S & """, length =" & S'Length'Image);
      for I in S'First + 1 .. S'Last loop
         if S(I) /= S(S'First) then
            First_Diff := I;
            exit;
         end if;
      end loop;
      if First_Diff = 0 then
         Put_Line (" All characters are the same.");
      else
         Put (" First difference at position" & First_Diff'Image &
              ", character = '" & S(First_Diff) &
              "', hex = ");
         Put (Character'Pos (S(First_Diff)), Width => 0, Base => 16);
         New_Line;
      end if;
   end All_Chars_Are_Same;
begin
   All_Chars_Are_Same ("");
   All_Chars_Are_Same ("   ");
   All_Chars_Are_Same ("2");
   All_Chars_Are_Same ("333");
   All_Chars_Are_Same (".55");
   All_Chars_Are_Same ("tttTTT");
   All_Chars_Are_Same ("4444 444k");
end Test_All_Chars_Are_Same;
Task: Determine if a string has all the same characters

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

int main(int argc,char** argv)
{
    int i,len;
    char reference;
    
    if(argc>2){
        printf("Usage : %s <Test String>\n",argv[0]);
        return 0;
    }

    if(argc==1||strlen(argv[1])==1){
        printf("Input string : \"%s\"\nLength : %d\nAll characters are identical.\n",argc==1?"":argv[1],argc==1?0:(int)strlen(argv[1]));
        return 0;
    }

    reference = argv[1][0];
    len = strlen(argv[1]);

    for(i=1;i<len;i++){
        if(argv[1][i]!=reference){
            printf("Input string : \"%s\"\nLength : %d\nFirst different character : \"%c\"(0x%x) at position : %d\n",argv[1],len,argv[1][i],argv[1][i],i+1);
            return 0;
        }
    }

    printf("Input string : \"%s\"\nLength : %d\nAll characters are identical.\n",argv[1],len);

    return 0;

}











Ada: with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_All_Chars_Are_Same is
   procedure All_Chars_Are_Same (S : in String) is
      First_Diff : Natural := 0;
   begin
      Put_Line ("Input = """ & S & """, length =" & S'Length'Image);
      for I in S'First + 1 .. S'Last loop
         if S(I) /= S(S'First) then
            First_Diff := I;
            exit;
         end if;
      end loop;
      if First_Diff = 0 then
         Put_Line (" All characters are the same.");
      else
         Put (" First difference at position" & First_Diff'Image &
              ", character = '" & S(First_Diff) &
              "', hex = ");
         Put (Character'Pos (S(First_Diff)), Width => 0, Base => 16);
         New_Line;
      end if;
   end All_Chars_Are_Same;
begin
   All_Chars_Are_Same ("");
   All_Chars_Are_Same ("   ");
   All_Chars_Are_Same ("2");
   All_Chars_Are_Same ("333");
   All_Chars_Are_Same (".55");
   All_Chars_Are_Same ("tttTTT");
   All_Chars_Are_Same ("4444 444k");
end Test_All_Chars_Are_Same;
Task: Determine if a string has all the same characters


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

void all_characters_are_the_same(const std::string& str) {
    size_t len = str.length();
    std::cout << "input: \"" << str << "\", length: " << len << '\n';
    if (len > 0) {
        char ch = str[0];
        for (size_t i = 1; i < len; ++i) {
            if (str[i] != ch) {
                std::cout << "Not all characters are the same.\n";
                std::cout << "Character '" << str[i]
                    << "' (hex " << std::hex << static_cast<unsigned int>(str[i])
                    << ") at position " << std::dec << i + 1
                    << " is not the same as '" << ch << "'.\n\n";
                return;
            }
        }
    }
    std::cout << "All characters are the same.\n\n";
}

int main() {
    all_characters_are_the_same("");
    all_characters_are_the_same("   ");
    all_characters_are_the_same("2");
    all_characters_are_the_same("333");
    all_characters_are_the_same(".55");
    all_characters_are_the_same("tttTTT");
    all_characters_are_the_same("4444 444k");
    return 0;
}










Ada: with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_All_Chars_Are_Same is
   procedure All_Chars_Are_Same (S : in String) is
      First_Diff : Natural := 0;
   begin
      Put_Line ("Input = """ & S & """, length =" & S'Length'Image);
      for I in S'First + 1 .. S'Last loop
         if S(I) /= S(S'First) then
            First_Diff := I;
            exit;
         end if;
      end loop;
      if First_Diff = 0 then
         Put_Line (" All characters are the same.");
      else
         Put (" First difference at position" & First_Diff'Image &
              ", character = '" & S(First_Diff) &
              "', hex = ");
         Put (Character'Pos (S(First_Diff)), Width => 0, Base => 16);
         New_Line;
      end if;
   end All_Chars_Are_Same;
begin
   All_Chars_Are_Same ("");
   All_Chars_Are_Same ("   ");
   All_Chars_Are_Same ("2");
   All_Chars_Are_Same ("333");
   All_Chars_Are_Same (".55");
   All_Chars_Are_Same ("tttTTT");
   All_Chars_Are_Same ("4444 444k");
end Test_All_Chars_Are_Same;
Task: Determine if a string has all the same characters




Go: package main

import "fmt"

func analyze(s string) {
    chars := []rune(s)
    le := len(chars)
    fmt.Printf("Analyzing %q which has a length of %d:\n", s, le)
    if le > 1 {
        for i := 1; i < le; i++ {
            if chars[i] != chars[i-1] {
                fmt.Println("  Not all characters in the string are the same.")
                fmt.Printf("  %q (%#[1]x) is different at position %d.\n\n", chars[i], i+1)
                return
            }
        }
    }
    fmt.Println("  All characters in the string are the same.\n")
}

func main() {
    strings := []string{
        "",
        "   ",
        "2",
        "333",
        ".55",
        "tttTTT",
        "4444 444k",
        "pépé",
        "🐶🐶🐺🐶",
        "🎄🎄🎄🎄",
    }
    for _, s := range strings {
        analyze(s)
    }
}








Ada: with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_All_Chars_Are_Same is
   procedure All_Chars_Are_Same (S : in String) is
      First_Diff : Natural := 0;
   begin
      Put_Line ("Input = """ & S & """, length =" & S'Length'Image);
      for I in S'First + 1 .. S'Last loop
         if S(I) /= S(S'First) then
            First_Diff := I;
            exit;
         end if;
      end loop;
      if First_Diff = 0 then
         Put_Line (" All characters are the same.");
      else
         Put (" First difference at position" & First_Diff'Image &
              ", character = '" & S(First_Diff) &
              "', hex = ");
         Put (Character'Pos (S(First_Diff)), Width => 0, Base => 16);
         New_Line;
      end if;
   end All_Chars_Are_Same;
begin
   All_Chars_Are_Same ("");
   All_Chars_Are_Same ("   ");
   All_Chars_Are_Same ("2");
   All_Chars_Are_Same ("333");
   All_Chars_Are_Same (".55");
   All_Chars_Are_Same ("tttTTT");
   All_Chars_Are_Same ("4444 444k");
end Test_All_Chars_Are_Same;
Task: Determine if a string has all the same characters





Java: public class Main{
	public static void main(String[] args){
		String[] tests = {"", "   ", "2", "333", ".55", "tttTTT", "4444 444k"};
		for(String s:tests)
			analyze(s);
	}

	public static void analyze(String s){
		System.out.printf("Examining [%s] which has a length of %d:\n", s, s.length());
		if(s.length() > 1){
			char firstChar = s.charAt(0);
			int lastIndex = s.lastIndexOf(firstChar);
			if(lastIndex != 0){
				System.out.println("\tNot all characters in the string are the same.");
				System.out.printf("\t'%c' (0x%x) is different at position %d\n", firstChar, (int) firstChar, lastIndex);
				return;
			}
		}
		System.out.println("\tAll characters in the string are the same.");
	}
}







Ada: with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_All_Chars_Are_Same is
   procedure All_Chars_Are_Same (S : in String) is
      First_Diff : Natural := 0;
   begin
      Put_Line ("Input = """ & S & """, length =" & S'Length'Image);
      for I in S'First + 1 .. S'Last loop
         if S(I) /= S(S'First) then
            First_Diff := I;
            exit;
         end if;
      end loop;
      if First_Diff = 0 then
         Put_Line (" All characters are the same.");
      else
         Put (" First difference at position" & First_Diff'Image &
              ", character = '" & S(First_Diff) &
              "', hex = ");
         Put (Character'Pos (S(First_Diff)), Width => 0, Base => 16);
         New_Line;
      end if;
   end All_Chars_Are_Same;
begin
   All_Chars_Are_Same ("");
   All_Chars_Are_Same ("   ");
   All_Chars_Are_Same ("2");
   All_Chars_Are_Same ("333");
   All_Chars_Are_Same (".55");
   All_Chars_Are_Same ("tttTTT");
   All_Chars_Are_Same ("4444 444k");
end Test_All_Chars_Are_Same;
Task: Determine if a string has all the same characters







Python: 

from itertools import groupby



def firstDifferingCharLR(s):
    
    def details(xs):
        c = xs[1][0]
        return {
            'char': repr(c),
            'hex': hex(ord(c)),
            'index': s.index(c),
            'total': len(s)
        }
    xs = list(groupby(s))
    return Right(details(xs)) if 1 < len(xs) else (
        Left('Total length ' + str(len(s)) + ' - No character changes.')
    )




def main():
    

    print(fTable('First, if any, points of difference:\n')(repr)(
        either(identity)(
            lambda dct: dct['char'] + ' (' + dct['hex'] +
            ') at character ' + str(1 + dct['index']) +
            ' of ' + str(dct['total']) + '.'
        )
    )(firstDifferingCharLR)([
        '',
        '   ',
        '2',
        '333',
        '.55',
        'tttTTT',
        '4444 444'
    ]))





def either(fl):
    
    return lambda fr: lambda e: fl(e['Left']) if (
        None is e['Right']
    ) else fr(e['Right'])



def identity(x):
    
    return x




def fTable(s):
    
    def go(xShow, fxShow, f, xs):
        ys = [xShow(x) for x in xs]
        w = max(map(len, ys))
        return s + '\n' + '\n'.join(map(
            lambda x, y: y.rjust(w, ' ') + ' -> ' + fxShow(f(x)),
            xs, ys
        ))
    return lambda xShow: lambda fxShow: lambda f: lambda xs: go(
        xShow, fxShow, f, xs
    )



def Left(x):
    
    return {'type': 'Either', 'Right': None, 'Left': x}



def Right(x):
    
    return {'type': 'Either', 'Left': None, 'Right': x}



if __name__ == '__main__':
    main()





Ada: with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_All_Chars_Are_Same is
   procedure All_Chars_Are_Same (S : in String) is
      First_Diff : Natural := 0;
   begin
      Put_Line ("Input = """ & S & """, length =" & S'Length'Image);
      for I in S'First + 1 .. S'Last loop
         if S(I) /= S(S'First) then
            First_Diff := I;
            exit;
         end if;
      end loop;
      if First_Diff = 0 then
         Put_Line (" All characters are the same.");
      else
         Put (" First difference at position" & First_Diff'Image &
              ", character = '" & S(First_Diff) &
              "', hex = ");
         Put (Character'Pos (S(First_Diff)), Width => 0, Base => 16);
         New_Line;
      end if;
   end All_Chars_Are_Same;
begin
   All_Chars_Are_Same ("");
   All_Chars_Are_Same ("   ");
   All_Chars_Are_Same ("2");
   All_Chars_Are_Same ("333");
   All_Chars_Are_Same (".55");
   All_Chars_Are_Same ("tttTTT");
   All_Chars_Are_Same ("4444 444k");
end Test_All_Chars_Are_Same;