kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Deal cards for FreeCell
C++: #include <windows.h>
#include <iostream>


using namespace std;


class fc_dealer
{
public:
    void deal( int game )
    {
	_gn = game;
	fillDeck();
	shuffle();
	display();
    }

private:
    void fillDeck()
    {
	int p = 0;
	for( int c = 0; c < 13; c++ )
	    for( int s = 0; s < 4; s++ )
		_cards[p++] = c | s << 4;
    }

    void shuffle()
    {
	srand( _gn );
	int cc = 52, nc, lc;
	while( cc )
	{
	    nc = rand() % cc;
	    lc = _cards[--cc];
	    _cards[cc] = _cards[nc];
	    _cards[nc] = lc;
	}
    }

    void display()
    {
	char* suit = "CDHS";
	char* symb = "A23456789TJQK";
	int z = 0;
	cout << "GAME #" << _gn << endl << "=======================" << endl;
	for( int c = 51; c >= 0; c-- )
	{
	    cout << symb[_cards[c] & 15] << suit[_cards[c] >> 4] << " ";
	    if( ++z >= 8 )
	    {
		cout << endl;
		z = 0;
	    }
	}
    }

    int _cards[52], _gn;
};

int main( int argc, char* argv[] )
{
    fc_dealer dealer;
    int gn;
    while( true )
    {
	cout << endl << "Game number please ( 0 to QUIT ): "; cin >> gn;
	if( !gn ) break;

	system( "cls" );
	dealer.deal( gn );
	cout << endl << endl;
    }
    return 0;
}


Python: def randomGenerator(seed=1):
    max_int32 = (1 << 31) - 1
    seed = seed & max_int32

    while True:
        seed = (seed * 214013 + 2531011) & max_int32
        yield seed >> 16

def deal(seed):
    nc = 52
    cards = list(range(nc - 1, -1, -1))
    rnd = randomGenerator(seed)
    for i, r in zip(range(nc), rnd):
        j = (nc - 1) - r % (nc - i)
        cards[i], cards[j] = cards[j], cards[i]
    return cards

def show(cards):
    l = ["A23456789TJQK"[int(c/4)] + "CDHS"[c%4] for c in cards]
    for i in range(0, len(cards), 8):
        print(" ".join(l[i : i+8]))

if __name__ == '__main__':
    from sys import argv
    seed = int(argv[1]) if len(argv) == 2 else 11982
    print("Hand {}".format(seed))
    deck = deal(seed)
    show(deck)
Task: Deal cards for FreeCell
Java: import java.util.Arrays;

public class Shuffler {
	
	private int seed;
	
	private String[] deck = {
			"AC", "AD", "AH", "AS",
			"2C", "2D", "2H", "2S",
			"3C", "3D", "3H", "3S",
			"4C", "4D", "4H", "4S",
			"5C", "5D", "5H", "5S",
			"6C", "6D", "6H", "6S",
			"7C", "7D", "7H", "7S",
			"8C", "8D", "8H", "8S",
			"9C", "9D", "9H", "9S",
			"TC", "TD", "TH", "TS",
			"JC", "JD", "JH", "JS",
			"QC", "QD", "QH", "QS",
			"KC", "KD", "KH", "KS",
	};
	
	private int random() {
		seed = (214013 * seed + 2531011) & Integer.MAX_VALUE;
		return seed >> 16;
	}
	
	
	private String[] getShuffledDeck() {
		String[] deck = Arrays.copyOf(this.deck, this.deck.length);
		for(int i = deck.length - 1; i > 0; i--) {
			int r = random() % (i + 1);
			String card = deck[r];
			deck[r] = deck[i];
			deck[i] = card;
		}
		return deck;
	}
	
	
	public void dealGame(int seed) {
		this.seed = seed;
		String[] shuffledDeck = getShuffledDeck();
		for(int count = 1, i = shuffledDeck.length - 1; i >= 0; count++, i--) {
			System.out.print(shuffledDeck[i]);
			if(count % 8 == 0) {
				System.out.println();
			} else {
				System.out.print(" ");
			}
		}
		System.out.println();
	}
	
	public static void main(String[] args) {
		Shuffler s = new Shuffler();
		s.dealGame(1);
		System.out.println();
		s.dealGame(617);
	}
	
}

Python: def randomGenerator(seed=1):
    max_int32 = (1 << 31) - 1
    seed = seed & max_int32

    while True:
        seed = (seed * 214013 + 2531011) & max_int32
        yield seed >> 16

def deal(seed):
    nc = 52
    cards = list(range(nc - 1, -1, -1))
    rnd = randomGenerator(seed)
    for i, r in zip(range(nc), rnd):
        j = (nc - 1) - r % (nc - i)
        cards[i], cards[j] = cards[j], cards[i]
    return cards

def show(cards):
    l = ["A23456789TJQK"[int(c/4)] + "CDHS"[c%4] for c in cards]
    for i in range(0, len(cards), 8):
        print(" ".join(l[i : i+8]))

if __name__ == '__main__':
    from sys import argv
    seed = int(argv[1]) if len(argv) == 2 else 11982
    print("Hand {}".format(seed))
    deck = deal(seed)
    show(deck)
Task: Deal cards for FreeCell
C: #include <stdio.h>
#include <stdlib.h>
#include <locale.h>

wchar_t s_suits[] = L"♣♦♥♠", s_nums[] = L"A23456789TJQK";

#define RMAX32 ((1U << 31) - 1)
static int seed = 1;
int  rnd(void) { return (seed = (seed * 214013 + 2531011) & RMAX32) >> 16; }
void srnd(int x) { seed = x; }

void show(const int *c)
{
	int i;
	for (i = 0; i < 52; c++) {
		printf("  \033[%dm%lc\033[m%lc", 32 - (1 + *c) % 4 / 2,
			s_suits[*c % 4], s_nums[*c / 4]);
		if (!(++i % 8) || i == 52) putchar('\n');
	}
}

void deal(int s, int *t)
{
	int i, j;
	srnd(s);

	for (i = 0; i < 52; i++) t[i] = 51 - i;
	for (i = 0; i < 51; i++) {
		j = 51 - rnd() % (52 - i);
		s = t[i], t[i] = t[j], t[j] = s;
	}
}

int main(int c, char **v)
{
	int s, card[52];
	if (c < 2 || (s = atoi(v[1])) <= 0) s = 11982;

	setlocale(LC_ALL, "");

	deal(s, card);
	printf("Hand %d\n", s);
	show(card);

	return 0;
}

PHP: class FreeCell_Deal {

    protected $deck = array( 
        'AC', 'AD', 'AH', 'AS', '2C', '2D', '2H', '2S', '3C', '3D', '3H', '3S',
        '4C', '4D', '4H', '4S', '5C', '5D', '5H', '5S', '6C', '6D', '6H', '6S', 
        '7C', '7D', '7H', '7S', '8C', '8D', '8H', '8S', '9C', '9D', '9H', '9S',
        'TC', 'TD', 'TH', 'TS', 'JC', 'JD', 'JH', 'JS', 'QC', 'QD', 'QH', 'QS', 
        'KC', 'KD', 'KH', 'KS'
    );
    
    protected $game;        // Freecell Game Number
    protected $state;       // Current state of the LCG

    public $deal = array(); // Generated card sequence to deal

    function __construct( $game ) {

        $this->game = max( min( $game, 32000 ), 1 );

        $this->state = $this->game;

        while ( ! empty( $this->deck ) ) {

            $i = $this->lcg_rnd() % count( $this->deck );

            $this->deal[] = $this->deck[ $i ];

            $this->deck[ $i ] = end( $this->deck );

            array_pop( $this->deck );

        }

    }

    protected function lcg_rnd() {
        return ( $this->state = ( $this->state * 214013 + 2531011 ) % 2147483648 ) >> 16;
    }

    function print( $cols = 8 ) {
        echo str_pad( " Game " . $this->game . " ", $cols * 3 - 1, '=', STR_PAD_BOTH ), PHP_EOL;
        foreach ( array_chunk( $this->deal, $cols ) as $row ) {
            echo implode( " ", $row ), PHP_EOL;
        }
        echo PHP_EOL;
    }

}

$tests = array( 1, 617, 11982 );

foreach ( $tests as $game_num ) {
    $deal = new FreeCell_Deal( $game_num ); 
    $deal->print();
}
Task: Deal cards for FreeCell
C++: #include <windows.h>
#include <iostream>


using namespace std;


class fc_dealer
{
public:
    void deal( int game )
    {
	_gn = game;
	fillDeck();
	shuffle();
	display();
    }

private:
    void fillDeck()
    {
	int p = 0;
	for( int c = 0; c < 13; c++ )
	    for( int s = 0; s < 4; s++ )
		_cards[p++] = c | s << 4;
    }

    void shuffle()
    {
	srand( _gn );
	int cc = 52, nc, lc;
	while( cc )
	{
	    nc = rand() % cc;
	    lc = _cards[--cc];
	    _cards[cc] = _cards[nc];
	    _cards[nc] = lc;
	}
    }

    void display()
    {
	char* suit = "CDHS";
	char* symb = "A23456789TJQK";
	int z = 0;
	cout << "GAME #" << _gn << endl << "=======================" << endl;
	for( int c = 51; c >= 0; c-- )
	{
	    cout << symb[_cards[c] & 15] << suit[_cards[c] >> 4] << " ";
	    if( ++z >= 8 )
	    {
		cout << endl;
		z = 0;
	    }
	}
    }

    int _cards[52], _gn;
};

int main( int argc, char* argv[] )
{
    fc_dealer dealer;
    int gn;
    while( true )
    {
	cout << endl << "Game number please ( 0 to QUIT ): "; cin >> gn;
	if( !gn ) break;

	system( "cls" );
	dealer.deal( gn );
	cout << endl << endl;
    }
    return 0;
}


PHP: class FreeCell_Deal {

    protected $deck = array( 
        'AC', 'AD', 'AH', 'AS', '2C', '2D', '2H', '2S', '3C', '3D', '3H', '3S',
        '4C', '4D', '4H', '4S', '5C', '5D', '5H', '5S', '6C', '6D', '6H', '6S', 
        '7C', '7D', '7H', '7S', '8C', '8D', '8H', '8S', '9C', '9D', '9H', '9S',
        'TC', 'TD', 'TH', 'TS', 'JC', 'JD', 'JH', 'JS', 'QC', 'QD', 'QH', 'QS', 
        'KC', 'KD', 'KH', 'KS'
    );
    
    protected $game;        // Freecell Game Number
    protected $state;       // Current state of the LCG

    public $deal = array(); // Generated card sequence to deal

    function __construct( $game ) {

        $this->game = max( min( $game, 32000 ), 1 );

        $this->state = $this->game;

        while ( ! empty( $this->deck ) ) {

            $i = $this->lcg_rnd() % count( $this->deck );

            $this->deal[] = $this->deck[ $i ];

            $this->deck[ $i ] = end( $this->deck );

            array_pop( $this->deck );

        }

    }

    protected function lcg_rnd() {
        return ( $this->state = ( $this->state * 214013 + 2531011 ) % 2147483648 ) >> 16;
    }

    function print( $cols = 8 ) {
        echo str_pad( " Game " . $this->game . " ", $cols * 3 - 1, '=', STR_PAD_BOTH ), PHP_EOL;
        foreach ( array_chunk( $this->deal, $cols ) as $row ) {
            echo implode( " ", $row ), PHP_EOL;
        }
        echo PHP_EOL;
    }

}

$tests = array( 1, 617, 11982 );

foreach ( $tests as $game_num ) {
    $deal = new FreeCell_Deal( $game_num ); 
    $deal->print();
}
Task: Deal cards for FreeCell
Go: package main

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

const sSuits = "CDHS"
const sNums = "A23456789TJQK"
const rMax32 = math.MaxInt32

var seed = 1

func rnd() int {
    seed = (seed*214013 + 2531011) & rMax32
    return seed >> 16
}

func deal(s int) []int {
    seed = s
    t := make([]int, 52)
    for i := 0; i < 52; i++ {
        t[i] = 51 - i
    }
    for i := 0; i < 51; i++ {
        j := 51 - rnd()%(52-i)
        t[i], t[j] = t[j], t[i]
    }
    return t
}

func show(cs []int) {
    for i, c := range cs {
        fmt.Printf(" %c%c", sNums[c/4], sSuits[c%4])
        if (i+1)%8 == 0 || i+1 == len(cs) {
            fmt.Println()
        }
    }
}

func main() {
    var game int
    switch len(os.Args) {
    case 1:
        rand.Seed(time.Now().UnixNano())
        game = 1 + rand.Intn(32000)
    case 2:
        var err error
        game, err = strconv.Atoi(os.Args[1])
        if err == nil && game >= 1 && game <= 32000 {
            break
        }
        fallthrough
    default:
        fmt.Println("usage: deal [game]")
        fmt.Println("       where game is a number in the range 1 to 32000")
        return
    }
    fmt.Printf("\nGame #%d\n", game)
    show(deal(game))
}

PHP: class FreeCell_Deal {

    protected $deck = array( 
        'AC', 'AD', 'AH', 'AS', '2C', '2D', '2H', '2S', '3C', '3D', '3H', '3S',
        '4C', '4D', '4H', '4S', '5C', '5D', '5H', '5S', '6C', '6D', '6H', '6S', 
        '7C', '7D', '7H', '7S', '8C', '8D', '8H', '8S', '9C', '9D', '9H', '9S',
        'TC', 'TD', 'TH', 'TS', 'JC', 'JD', 'JH', 'JS', 'QC', 'QD', 'QH', 'QS', 
        'KC', 'KD', 'KH', 'KS'
    );
    
    protected $game;        // Freecell Game Number
    protected $state;       // Current state of the LCG

    public $deal = array(); // Generated card sequence to deal

    function __construct( $game ) {

        $this->game = max( min( $game, 32000 ), 1 );

        $this->state = $this->game;

        while ( ! empty( $this->deck ) ) {

            $i = $this->lcg_rnd() % count( $this->deck );

            $this->deal[] = $this->deck[ $i ];

            $this->deck[ $i ] = end( $this->deck );

            array_pop( $this->deck );

        }

    }

    protected function lcg_rnd() {
        return ( $this->state = ( $this->state * 214013 + 2531011 ) % 2147483648 ) >> 16;
    }

    function print( $cols = 8 ) {
        echo str_pad( " Game " . $this->game . " ", $cols * 3 - 1, '=', STR_PAD_BOTH ), PHP_EOL;
        foreach ( array_chunk( $this->deal, $cols ) as $row ) {
            echo implode( " ", $row ), PHP_EOL;
        }
        echo PHP_EOL;
    }

}

$tests = array( 1, 617, 11982 );

foreach ( $tests as $game_num ) {
    $deal = new FreeCell_Deal( $game_num ); 
    $deal->print();
}
Task: Deal cards for FreeCell
Java: import java.util.Arrays;

public class Shuffler {
	
	private int seed;
	
	private String[] deck = {
			"AC", "AD", "AH", "AS",
			"2C", "2D", "2H", "2S",
			"3C", "3D", "3H", "3S",
			"4C", "4D", "4H", "4S",
			"5C", "5D", "5H", "5S",
			"6C", "6D", "6H", "6S",
			"7C", "7D", "7H", "7S",
			"8C", "8D", "8H", "8S",
			"9C", "9D", "9H", "9S",
			"TC", "TD", "TH", "TS",
			"JC", "JD", "JH", "JS",
			"QC", "QD", "QH", "QS",
			"KC", "KD", "KH", "KS",
	};
	
	private int random() {
		seed = (214013 * seed + 2531011) & Integer.MAX_VALUE;
		return seed >> 16;
	}
	
	
	private String[] getShuffledDeck() {
		String[] deck = Arrays.copyOf(this.deck, this.deck.length);
		for(int i = deck.length - 1; i > 0; i--) {
			int r = random() % (i + 1);
			String card = deck[r];
			deck[r] = deck[i];
			deck[i] = card;
		}
		return deck;
	}
	
	
	public void dealGame(int seed) {
		this.seed = seed;
		String[] shuffledDeck = getShuffledDeck();
		for(int count = 1, i = shuffledDeck.length - 1; i >= 0; count++, i--) {
			System.out.print(shuffledDeck[i]);
			if(count % 8 == 0) {
				System.out.println();
			} else {
				System.out.print(" ");
			}
		}
		System.out.println();
	}
	
	public static void main(String[] args) {
		Shuffler s = new Shuffler();
		s.dealGame(1);
		System.out.println();
		s.dealGame(617);
	}
	
}

PHP: class FreeCell_Deal {

    protected $deck = array( 
        'AC', 'AD', 'AH', 'AS', '2C', '2D', '2H', '2S', '3C', '3D', '3H', '3S',
        '4C', '4D', '4H', '4S', '5C', '5D', '5H', '5S', '6C', '6D', '6H', '6S', 
        '7C', '7D', '7H', '7S', '8C', '8D', '8H', '8S', '9C', '9D', '9H', '9S',
        'TC', 'TD', 'TH', 'TS', 'JC', 'JD', 'JH', 'JS', 'QC', 'QD', 'QH', 'QS', 
        'KC', 'KD', 'KH', 'KS'
    );
    
    protected $game;        // Freecell Game Number
    protected $state;       // Current state of the LCG

    public $deal = array(); // Generated card sequence to deal

    function __construct( $game ) {

        $this->game = max( min( $game, 32000 ), 1 );

        $this->state = $this->game;

        while ( ! empty( $this->deck ) ) {

            $i = $this->lcg_rnd() % count( $this->deck );

            $this->deal[] = $this->deck[ $i ];

            $this->deck[ $i ] = end( $this->deck );

            array_pop( $this->deck );

        }

    }

    protected function lcg_rnd() {
        return ( $this->state = ( $this->state * 214013 + 2531011 ) % 2147483648 ) >> 16;
    }

    function print( $cols = 8 ) {
        echo str_pad( " Game " . $this->game . " ", $cols * 3 - 1, '=', STR_PAD_BOTH ), PHP_EOL;
        foreach ( array_chunk( $this->deal, $cols ) as $row ) {
            echo implode( " ", $row ), PHP_EOL;
        }
        echo PHP_EOL;
    }

}

$tests = array( 1, 617, 11982 );

foreach ( $tests as $game_num ) {
    $deal = new FreeCell_Deal( $game_num ); 
    $deal->print();
}
Task: Deal cards for FreeCell
Python: def randomGenerator(seed=1):
    max_int32 = (1 << 31) - 1
    seed = seed & max_int32

    while True:
        seed = (seed * 214013 + 2531011) & max_int32
        yield seed >> 16

def deal(seed):
    nc = 52
    cards = list(range(nc - 1, -1, -1))
    rnd = randomGenerator(seed)
    for i, r in zip(range(nc), rnd):
        j = (nc - 1) - r % (nc - i)
        cards[i], cards[j] = cards[j], cards[i]
    return cards

def show(cards):
    l = ["A23456789TJQK"[int(c/4)] + "CDHS"[c%4] for c in cards]
    for i in range(0, len(cards), 8):
        print(" ".join(l[i : i+8]))

if __name__ == '__main__':
    from sys import argv
    seed = int(argv[1]) if len(argv) == 2 else 11982
    print("Hand {}".format(seed))
    deck = deal(seed)
    show(deck)

PHP: class FreeCell_Deal {

    protected $deck = array( 
        'AC', 'AD', 'AH', 'AS', '2C', '2D', '2H', '2S', '3C', '3D', '3H', '3S',
        '4C', '4D', '4H', '4S', '5C', '5D', '5H', '5S', '6C', '6D', '6H', '6S', 
        '7C', '7D', '7H', '7S', '8C', '8D', '8H', '8S', '9C', '9D', '9H', '9S',
        'TC', 'TD', 'TH', 'TS', 'JC', 'JD', 'JH', 'JS', 'QC', 'QD', 'QH', 'QS', 
        'KC', 'KD', 'KH', 'KS'
    );
    
    protected $game;        // Freecell Game Number
    protected $state;       // Current state of the LCG

    public $deal = array(); // Generated card sequence to deal

    function __construct( $game ) {

        $this->game = max( min( $game, 32000 ), 1 );

        $this->state = $this->game;

        while ( ! empty( $this->deck ) ) {

            $i = $this->lcg_rnd() % count( $this->deck );

            $this->deal[] = $this->deck[ $i ];

            $this->deck[ $i ] = end( $this->deck );

            array_pop( $this->deck );

        }

    }

    protected function lcg_rnd() {
        return ( $this->state = ( $this->state * 214013 + 2531011 ) % 2147483648 ) >> 16;
    }

    function print( $cols = 8 ) {
        echo str_pad( " Game " . $this->game . " ", $cols * 3 - 1, '=', STR_PAD_BOTH ), PHP_EOL;
        foreach ( array_chunk( $this->deal, $cols ) as $row ) {
            echo implode( " ", $row ), PHP_EOL;
        }
        echo PHP_EOL;
    }

}

$tests = array( 1, 617, 11982 );

foreach ( $tests as $game_num ) {
    $deal = new FreeCell_Deal( $game_num ); 
    $deal->print();
}
Task: Comma quibbling
C: #include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *quib(const char **strs, size_t size)
{

    size_t len = 3 + ((size > 1) ? (2 * size + 1) : 0);
    size_t i;

    for (i = 0; i < size; i++)
        len += strlen(strs[i]);

    char *s = malloc(len * sizeof(*s));
    if (!s)
    {
        perror("Can't allocate memory!\n");
        exit(EXIT_FAILURE);
    }

    strcpy(s, "{");
    switch (size) {
        case 0:  break;
        case 1:  strcat(s, strs[0]);
                 break;
        default: for (i = 0; i < size - 1; i++)
                 {
                     strcat(s, strs[i]);
                     if (i < size - 2)
                         strcat(s, ", ");
                     else
                         strcat(s, " and ");
                 }
                 strcat(s, strs[i]);
                 break;
    }  
    strcat(s, "}");
    return s;
}

int main(void)
{
    const char *test[] = {"ABC", "DEF", "G", "H"};
    char *s;

    for (size_t i = 0; i < 5; i++)
    {
        s = quib(test, i);
        printf("%s\n", s);
        free(s);
    }
    return EXIT_SUCCESS;
}

C#: using System;
using System.Linq;

namespace CommaQuibbling
{
    internal static class Program
    {
        #region Static Members
	private static string Quibble(string[] input)
	{
            return
                String.Format("{{{0}}}",
                    String.Join("",
                        input.Reverse().Zip(
                            new [] { "", " and " }.Concat(Enumerable.Repeat(", ", int.MaxValue)),
                            (x, y) => x + y).Reverse()));
	}


        private static void Main()
        {
            Console.WriteLine( Quibble( new string[] {} ) );
            Console.WriteLine( Quibble( new[] {"ABC"} ) );
            Console.WriteLine( Quibble( new[] {"ABC", "DEF"} ) );
            Console.WriteLine( Quibble( new[] {"ABC", "DEF", "G", "H"} ) );

            Console.WriteLine( "< Press Any Key >" );
            Console.ReadKey();
        }

        #endregion
    }
}
Task: Comma quibbling
C: #include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *quib(const char **strs, size_t size)
{

    size_t len = 3 + ((size > 1) ? (2 * size + 1) : 0);
    size_t i;

    for (i = 0; i < size; i++)
        len += strlen(strs[i]);

    char *s = malloc(len * sizeof(*s));
    if (!s)
    {
        perror("Can't allocate memory!\n");
        exit(EXIT_FAILURE);
    }

    strcpy(s, "{");
    switch (size) {
        case 0:  break;
        case 1:  strcat(s, strs[0]);
                 break;
        default: for (i = 0; i < size - 1; i++)
                 {
                     strcat(s, strs[i]);
                     if (i < size - 2)
                         strcat(s, ", ");
                     else
                         strcat(s, " and ");
                 }
                 strcat(s, strs[i]);
                 break;
    }  
    strcat(s, "}");
    return s;
}

int main(void)
{
    const char *test[] = {"ABC", "DEF", "G", "H"};
    char *s;

    for (size_t i = 0; i < 5; i++)
    {
        s = quib(test, i);
        printf("%s\n", s);
        free(s);
    }
    return EXIT_SUCCESS;
}

C++: #include <iostream>

template<class T>
void quibble(std::ostream& o, T i, T e) {
  o << "{";
  if (e != i) {
    T n = i++;
    const char* more = "";
    while (e != i) {
      o << more << *n;
      more = ", ";
      n = i++;
    }
    o << (*more?" and ":"") << *n;
  }
  o << "}";
}

int main(int argc, char** argv) {
  char const* a[] = {"ABC","DEF","G","H"};
  for (int i=0; i<5; i++) {
    quibble(std::cout, a, a+i);
    std::cout << std::endl;
  }
  return 0;
}
Task: Comma quibbling
C: #include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *quib(const char **strs, size_t size)
{

    size_t len = 3 + ((size > 1) ? (2 * size + 1) : 0);
    size_t i;

    for (i = 0; i < size; i++)
        len += strlen(strs[i]);

    char *s = malloc(len * sizeof(*s));
    if (!s)
    {
        perror("Can't allocate memory!\n");
        exit(EXIT_FAILURE);
    }

    strcpy(s, "{");
    switch (size) {
        case 0:  break;
        case 1:  strcat(s, strs[0]);
                 break;
        default: for (i = 0; i < size - 1; i++)
                 {
                     strcat(s, strs[i]);
                     if (i < size - 2)
                         strcat(s, ", ");
                     else
                         strcat(s, " and ");
                 }
                 strcat(s, strs[i]);
                 break;
    }  
    strcat(s, "}");
    return s;
}

int main(void)
{
    const char *test[] = {"ABC", "DEF", "G", "H"};
    char *s;

    for (size_t i = 0; i < 5; i++)
    {
        s = quib(test, i);
        printf("%s\n", s);
        free(s);
    }
    return EXIT_SUCCESS;
}

Go: package main

import (
    "fmt"
    "strings"
)

func q(s []string) string {
    switch len(s) {
    case 0:
        return "{}"
    case 1:
        return "{" + s[0] + "}"
    case 2:
        return "{" + s[0] + " and " + s[1] + "}"
    default:
        return "{" +
            strings.Join(s[:len(s)-1], ", ") +
            " and " +
            s[len(s)-1] +
            "}"
    }
}

func main() {
    fmt.Println(q([]string{}))
    fmt.Println(q([]string{"ABC"}))
    fmt.Println(q([]string{"ABC", "DEF"}))
    fmt.Println(q([]string{"ABC", "DEF", "G", "H"}))
}
Task: Comma quibbling
C: #include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *quib(const char **strs, size_t size)
{

    size_t len = 3 + ((size > 1) ? (2 * size + 1) : 0);
    size_t i;

    for (i = 0; i < size; i++)
        len += strlen(strs[i]);

    char *s = malloc(len * sizeof(*s));
    if (!s)
    {
        perror("Can't allocate memory!\n");
        exit(EXIT_FAILURE);
    }

    strcpy(s, "{");
    switch (size) {
        case 0:  break;
        case 1:  strcat(s, strs[0]);
                 break;
        default: for (i = 0; i < size - 1; i++)
                 {
                     strcat(s, strs[i]);
                     if (i < size - 2)
                         strcat(s, ", ");
                     else
                         strcat(s, " and ");
                 }
                 strcat(s, strs[i]);
                 break;
    }  
    strcat(s, "}");
    return s;
}

int main(void)
{
    const char *test[] = {"ABC", "DEF", "G", "H"};
    char *s;

    for (size_t i = 0; i < 5; i++)
    {
        s = quib(test, i);
        printf("%s\n", s);
        free(s);
    }
    return EXIT_SUCCESS;
}

Java: public class Quibbler {

	public static String quibble(String[] words) {
		String qText = "{";
		for(int wIndex = 0; wIndex < words.length; wIndex++) {
			qText += words[wIndex] + (wIndex == words.length-1 ? "" : 
						  wIndex == words.length-2 ? " and " :
						  ", ";
		}
		qText += "}";
		return qText;
	}
	
	public static void main(String[] args) {
		System.out.println(quibble(new String[]{}));
		System.out.println(quibble(new String[]{"ABC"}));
		System.out.println(quibble(new String[]{"ABC", "DEF"}));
		System.out.println(quibble(new String[]{"ABC", "DEF", "G"}));
		System.out.println(quibble(new String[]{"ABC", "DEF", "G", "H"}));
	}
}