kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Arithmetic_Complex
C: #include <complex.h>
#include <stdio.h>

void cprint(double complex c)
{
  printf("%f%+fI", creal(c), cimag(c));
}
void complex_operations() {
  double complex a = 1.0 + 1.0I;
  double complex b = 3.14159 + 1.2I;

  double complex c;

  printf("\na="); cprint(a);
  printf("\nb="); cprint(b);

  
  c = a + b;
  printf("\na+b="); cprint(c);
  
  c = a * b;
  printf("\na*b="); cprint(c);
  
  c = 1.0 / a;
  printf("\n1/c="); cprint(c);
  
  c = -a;
  printf("\n-a="); cprint(c);
  
  c = conj(a);
  printf("\nconj a="); cprint(c); printf("\n");
}

Python: >>> z1 = 1.5 + 3j
>>> z2 = 1.5 + 1.5j
>>> z1 + z2
(3+4.5j)
>>> z1 - z2
1.5j
>>> z1 * z2
(-2.25+6.75j)
>>> z1 / z2
(1.5+0.5j)
>>> - z1
(-1.5-3j)
>>> z1.conjugate()
(1.5-3j)
>>> abs(z1)
3.3541019662496847
>>> z1 ** z2
(-1.1024829553277784-0.38306415117199333j)
>>> z1.real
1.5
>>> z1.imag
3.0
>>>
Task: Arithmetic_Complex
Java: public class Complex {
    public final double real;
    public final double imag;

    public Complex() {
        this(0, 0);
    }

    public Complex(double r, double i) {
        real = r;
        imag = i;
    }

    public Complex add(Complex b) {
        return new Complex(this.real + b.real, this.imag + b.imag);
    }

    public Complex mult(Complex b) {
        
        return new Complex(this.real * b.real - this.imag * b.imag,
                this.real * b.imag + this.imag * b.real);
    }

    public Complex inv() {
        
        double denom = real * real + imag * imag;
        return new Complex(real / denom, -imag / denom);
    }

    public Complex neg() {
        return new Complex(-real, -imag);
    }

    public Complex conj() {
        return new Complex(real, -imag);
    }

    @Override
    public String toString() {
        return real + " + " + imag + " * i";
    }

    public static void main(String[] args) {
        Complex a = new Complex(Math.PI, -5); 
        Complex b = new Complex(-1, 2.5);
        System.out.println(a.neg());
        System.out.println(a.add(b));
        System.out.println(a.inv());
        System.out.println(a.mult(b));
        System.out.println(a.conj());
    }
}

Python: >>> z1 = 1.5 + 3j
>>> z2 = 1.5 + 1.5j
>>> z1 + z2
(3+4.5j)
>>> z1 - z2
1.5j
>>> z1 * z2
(-2.25+6.75j)
>>> z1 / z2
(1.5+0.5j)
>>> - z1
(-1.5-3j)
>>> z1.conjugate()
(1.5-3j)
>>> abs(z1)
3.3541019662496847
>>> z1 ** z2
(-1.1024829553277784-0.38306415117199333j)
>>> z1.real
1.5
>>> z1.imag
3.0
>>>
Task: Arithmetic_Complex
C#: namespace RosettaCode.Arithmetic.Complex
{
    using System;
    using System.Numerics;

    internal static class Program
    {
        private static void Main()
        {
            var number = Complex.ImaginaryOne;
            foreach (var result in new[] { number + number, number * number, -number, 1 / number, Complex.Conjugate(number) })
            {
                Console.WriteLine(result);
            }
        }
    }
}

C++: #include <iostream>
#include <complex>
using std::complex;

void complex_operations() {
  complex<double> a(1.0, 1.0);
  complex<double> b(3.14159, 1.25);

  
  std::cout << a + b << std::endl;
  
  std::cout << a * b << std::endl;
  
  std::cout << 1.0 / a << std::endl;
  
  std::cout << -a << std::endl;
  
  std::cout << std::conj(a) << std::endl;
}
Task: Arithmetic_Complex
C++: #include <iostream>
#include <complex>
using std::complex;

void complex_operations() {
  complex<double> a(1.0, 1.0);
  complex<double> b(3.14159, 1.25);

  
  std::cout << a + b << std::endl;
  
  std::cout << a * b << std::endl;
  
  std::cout << 1.0 / a << std::endl;
  
  std::cout << -a << std::endl;
  
  std::cout << std::conj(a) << std::endl;
}

Go: package main

import (
    "fmt"
    "math/cmplx"
)

func main() {
    a := 1 + 1i
    b := 3.14159 + 1.25i
    fmt.Println("a:      ", a)
    fmt.Println("b:      ", b)
    fmt.Println("a + b:  ", a+b)
    fmt.Println("a * b:  ", a*b)
    fmt.Println("-a:     ", -a)
    fmt.Println("1 / a:  ", 1/a)
    fmt.Println("a̅:      ", cmplx.Conj(a))
}
Task: Arithmetic_Complex
C#: namespace RosettaCode.Arithmetic.Complex
{
    using System;
    using System.Numerics;

    internal static class Program
    {
        private static void Main()
        {
            var number = Complex.ImaginaryOne;
            foreach (var result in new[] { number + number, number * number, -number, 1 / number, Complex.Conjugate(number) })
            {
                Console.WriteLine(result);
            }
        }
    }
}

Go: package main

import (
    "fmt"
    "math/cmplx"
)

func main() {
    a := 1 + 1i
    b := 3.14159 + 1.25i
    fmt.Println("a:      ", a)
    fmt.Println("b:      ", b)
    fmt.Println("a + b:  ", a+b)
    fmt.Println("a * b:  ", a*b)
    fmt.Println("-a:     ", -a)
    fmt.Println("1 / a:  ", 1/a)
    fmt.Println("a̅:      ", cmplx.Conj(a))
}
Task: RPG attributes generator
C: #include <stdio.h>
#include <stdlib.h>
#include <time.h>

int compareInts(const void *i1, const void *i2) {
    int a = *((int *)i1);
    int b = *((int *)i2);
    return a - b;
}

int main() {
    int i, j, nsum, vsum, vcount, values[6], numbers[4];
    srand(time(NULL));
    for (;;) {
        vsum = 0;
        for (i = 0; i < 6; ++i) {
            for (j = 0; j < 4; ++j) {
                numbers[j] = 1 + rand() % 6;
            }
            qsort(numbers, 4, sizeof(int), compareInts);
            nsum = 0;
            for (j = 1; j < 4; ++j) {
                nsum += numbers[j];
            }
            values[i] = nsum;
            vsum += values[i];
        }
        if (vsum < 75) continue;
        vcount = 0;
        for (j = 0; j < 6; ++j) {
            if (values[j] >= 15) vcount++;
        }
        if (vcount < 2) continue;
        printf("The 6 random numbers generated are:\n");
        printf("[");
        for (j = 0; j < 6; ++j) printf("%d ", values[j]);
        printf("\b]\n");
        printf("\nTheir sum is %d and %d of them are >= 15\n", vsum, vcount);
        break;
    }
    return 0;
}

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

static class Module1
{
    static Random r = new Random();

    static List<int> getThree(int n)
    {
        List<int> g3 = new List<int>();
        for (int i = 0; i < 4; i++) g3.Add(r.Next(n) + 1);
        g3.Sort(); g3.RemoveAt(0); return g3;
    }

    static List<int> getSix()
    {
        List<int> g6 = new List<int>();
        for (int i = 0; i < 6; i++) g6.Add(getThree(6).Sum());
        return g6;
    }

    static void Main(string[] args)
    {
        bool good = false; do {
            List<int> gs = getSix(); int gss = gs.Sum(); int hvc = gs.FindAll(x => x > 14).Count;
            Console.Write("attribs: {0}, sum={1}, ({2} sum, high vals={3})",
                          string.Join(", ", gs), gss, gss >= 75 ? "good" : "low", hvc);
            Console.WriteLine(" - {0}", (good = gs.Sum() >= 75 && hvc > 1) ? "success" : "failure");
        } while (!good);
    }
}
Task: RPG attributes generator
C: #include <stdio.h>
#include <stdlib.h>
#include <time.h>

int compareInts(const void *i1, const void *i2) {
    int a = *((int *)i1);
    int b = *((int *)i2);
    return a - b;
}

int main() {
    int i, j, nsum, vsum, vcount, values[6], numbers[4];
    srand(time(NULL));
    for (;;) {
        vsum = 0;
        for (i = 0; i < 6; ++i) {
            for (j = 0; j < 4; ++j) {
                numbers[j] = 1 + rand() % 6;
            }
            qsort(numbers, 4, sizeof(int), compareInts);
            nsum = 0;
            for (j = 1; j < 4; ++j) {
                nsum += numbers[j];
            }
            values[i] = nsum;
            vsum += values[i];
        }
        if (vsum < 75) continue;
        vcount = 0;
        for (j = 0; j < 6; ++j) {
            if (values[j] >= 15) vcount++;
        }
        if (vcount < 2) continue;
        printf("The 6 random numbers generated are:\n");
        printf("[");
        for (j = 0; j < 6; ++j) printf("%d ", values[j]);
        printf("\b]\n");
        printf("\nTheir sum is %d and %d of them are >= 15\n", vsum, vcount);
        break;
    }
    return 0;
}

Java: import java.util.List;
import java.util.Random;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toList;

public class Rpg {

    private static final Random random = new Random();
 
    public static int genAttribute() {
        return random.ints(1, 6 + 1) 
            .limit(4) 
            .sorted() 
            .limit(3) 
            .sum();   
    }
 
    public static void main(String[] args) {
        while (true) {
            List<Integer> stats =
                Stream.generate(Rpg::genAttribute) 
                    .limit(6) 
                    .collect(toList()); 
            int sum = stats.stream().mapToInt(Integer::intValue).sum();
            long count = stats.stream().filter(v -> v >= 15).count();
            if (count >= 2 && sum >= 75) {
                System.out.printf("The 6 random numbers generated are: %s\n", stats);
                System.out.printf("Their sum is %s and %s of them are >= 15\n", sum, count);
                return;
            }      
        }
    }
}
Task: RPG attributes generator
C: #include <stdio.h>
#include <stdlib.h>
#include <time.h>

int compareInts(const void *i1, const void *i2) {
    int a = *((int *)i1);
    int b = *((int *)i2);
    return a - b;
}

int main() {
    int i, j, nsum, vsum, vcount, values[6], numbers[4];
    srand(time(NULL));
    for (;;) {
        vsum = 0;
        for (i = 0; i < 6; ++i) {
            for (j = 0; j < 4; ++j) {
                numbers[j] = 1 + rand() % 6;
            }
            qsort(numbers, 4, sizeof(int), compareInts);
            nsum = 0;
            for (j = 1; j < 4; ++j) {
                nsum += numbers[j];
            }
            values[i] = nsum;
            vsum += values[i];
        }
        if (vsum < 75) continue;
        vcount = 0;
        for (j = 0; j < 6; ++j) {
            if (values[j] >= 15) vcount++;
        }
        if (vcount < 2) continue;
        printf("The 6 random numbers generated are:\n");
        printf("[");
        for (j = 0; j < 6; ++j) printf("%d ", values[j]);
        printf("\b]\n");
        printf("\nTheir sum is %d and %d of them are >= 15\n", vsum, vcount);
        break;
    }
    return 0;
}

Python: import random
random.seed()
attributes_total = 0
count = 0

while attributes_total < 75 or count < 2:
    attributes = []

    for attribute in range(0, 6):
        rolls = []
        
        for roll in range(0, 4):
            result = random.randint(1, 6)
            rolls.append(result)
        
        sorted_rolls = sorted(rolls)
        largest_3 = sorted_rolls[1:]
        rolls_total = sum(largest_3)
        
        if rolls_total >= 15:
            count += 1
        
        attributes.append(rolls_total)

    attributes_total = sum(attributes)
    
print(attributes_total, attributes)
Task: RPG attributes generator
C: #include <stdio.h>
#include <stdlib.h>
#include <time.h>

int compareInts(const void *i1, const void *i2) {
    int a = *((int *)i1);
    int b = *((int *)i2);
    return a - b;
}

int main() {
    int i, j, nsum, vsum, vcount, values[6], numbers[4];
    srand(time(NULL));
    for (;;) {
        vsum = 0;
        for (i = 0; i < 6; ++i) {
            for (j = 0; j < 4; ++j) {
                numbers[j] = 1 + rand() % 6;
            }
            qsort(numbers, 4, sizeof(int), compareInts);
            nsum = 0;
            for (j = 1; j < 4; ++j) {
                nsum += numbers[j];
            }
            values[i] = nsum;
            vsum += values[i];
        }
        if (vsum < 75) continue;
        vcount = 0;
        for (j = 0; j < 6; ++j) {
            if (values[j] >= 15) vcount++;
        }
        if (vcount < 2) continue;
        printf("The 6 random numbers generated are:\n");
        printf("[");
        for (j = 0; j < 6; ++j) printf("%d ", values[j]);
        printf("\b]\n");
        printf("\nTheir sum is %d and %d of them are >= 15\n", vsum, vcount);
        break;
    }
    return 0;
}

VB: Module Module1

    Dim r As New Random

    Function getThree(n As Integer) As List(Of Integer)
        getThree = New List(Of Integer)
        For i As Integer = 1 To 4 : getThree.Add(r.Next(n) + 1) : Next
        getThree.Sort() : getThree.RemoveAt(0)
    End Function

    Function getSix() As List(Of Integer)
        getSix = New List(Of Integer)
        For i As Integer = 1 To 6 : getSix.Add(getThree(6).Sum) : Next
    End Function

    Sub Main(args As String())
        Dim good As Boolean = False : Do
            Dim gs As List(Of Integer) = getSix(), gss As Integer = gs.Sum,
                hvc As Integer = gs.FindAll(Function(x) x > 14).Count
            Console.Write("attribs: {0}, sum={1}, ({2} sum, high vals={3})",
                          String.Join(", ", gs), gss, If(gss >= 75, "good", "low"), hvc)
            good = gs.Sum >= 75 AndAlso hvc > 1
            Console.WriteLine(" - {0}", If(good, "success", "failure"))
        Loop Until good
    End Sub
End Module
Task: RPG attributes generator
C#: using System;
using System.Collections.Generic;
using System.Linq;

static class Module1
{
    static Random r = new Random();

    static List<int> getThree(int n)
    {
        List<int> g3 = new List<int>();
        for (int i = 0; i < 4; i++) g3.Add(r.Next(n) + 1);
        g3.Sort(); g3.RemoveAt(0); return g3;
    }

    static List<int> getSix()
    {
        List<int> g6 = new List<int>();
        for (int i = 0; i < 6; i++) g6.Add(getThree(6).Sum());
        return g6;
    }

    static void Main(string[] args)
    {
        bool good = false; do {
            List<int> gs = getSix(); int gss = gs.Sum(); int hvc = gs.FindAll(x => x > 14).Count;
            Console.Write("attribs: {0}, sum={1}, ({2} sum, high vals={3})",
                          string.Join(", ", gs), gss, gss >= 75 ? "good" : "low", hvc);
            Console.WriteLine(" - {0}", (good = gs.Sum() >= 75 && hvc > 1) ? "success" : "failure");
        } while (!good);
    }
}

C++: #include <algorithm>
#include <ctime>
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
    srand(time(0));
    
    unsigned int attributes_total = 0;
    unsigned int count = 0;
    int attributes[6] = {};
    int rolls[4] = {};
    
    while(attributes_total < 75 || count < 2)
    {
        attributes_total = 0;
        count = 0;
        
        for(int attrib = 0; attrib < 6; attrib++)
        {            
            for(int roll = 0; roll < 4; roll++)
            {
                rolls[roll] = 1 + (rand() % 6);
            }
            
            sort(rolls, rolls + 4);
            int roll_total = rolls[1] + rolls[2] + rolls[3];            
                        
            attributes[attrib] = roll_total;
            attributes_total += roll_total;
            
            if(roll_total >= 15) count++;
        }
    }
    
    cout << "Attributes generated : [";
    cout << attributes[0] << ", ";
    cout << attributes[1] << ", ";
    cout << attributes[2] << ", ";
    cout << attributes[3] << ", ";
    cout << attributes[4] << ", ";
    cout << attributes[5];
    
    cout << "]\nTotal: " << attributes_total;
    cout << ", Values above 15 : " << count;
    
    return 0;
}
Task: RPG attributes generator
C++: #include <algorithm>
#include <ctime>
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
    srand(time(0));
    
    unsigned int attributes_total = 0;
    unsigned int count = 0;
    int attributes[6] = {};
    int rolls[4] = {};
    
    while(attributes_total < 75 || count < 2)
    {
        attributes_total = 0;
        count = 0;
        
        for(int attrib = 0; attrib < 6; attrib++)
        {            
            for(int roll = 0; roll < 4; roll++)
            {
                rolls[roll] = 1 + (rand() % 6);
            }
            
            sort(rolls, rolls + 4);
            int roll_total = rolls[1] + rolls[2] + rolls[3];            
                        
            attributes[attrib] = roll_total;
            attributes_total += roll_total;
            
            if(roll_total >= 15) count++;
        }
    }
    
    cout << "Attributes generated : [";
    cout << attributes[0] << ", ";
    cout << attributes[1] << ", ";
    cout << attributes[2] << ", ";
    cout << attributes[3] << ", ";
    cout << attributes[4] << ", ";
    cout << attributes[5];
    
    cout << "]\nTotal: " << attributes_total;
    cout << ", Values above 15 : " << count;
    
    return 0;
}

Java: import java.util.List;
import java.util.Random;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toList;

public class Rpg {

    private static final Random random = new Random();
 
    public static int genAttribute() {
        return random.ints(1, 6 + 1) 
            .limit(4) 
            .sorted() 
            .limit(3) 
            .sum();   
    }
 
    public static void main(String[] args) {
        while (true) {
            List<Integer> stats =
                Stream.generate(Rpg::genAttribute) 
                    .limit(6) 
                    .collect(toList()); 
            int sum = stats.stream().mapToInt(Integer::intValue).sum();
            long count = stats.stream().filter(v -> v >= 15).count();
            if (count >= 2 && sum >= 75) {
                System.out.printf("The 6 random numbers generated are: %s\n", stats);
                System.out.printf("Their sum is %s and %s of them are >= 15\n", sum, count);
                return;
            }      
        }
    }
}
Task: RPG attributes generator
C++: #include <algorithm>
#include <ctime>
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
    srand(time(0));
    
    unsigned int attributes_total = 0;
    unsigned int count = 0;
    int attributes[6] = {};
    int rolls[4] = {};
    
    while(attributes_total < 75 || count < 2)
    {
        attributes_total = 0;
        count = 0;
        
        for(int attrib = 0; attrib < 6; attrib++)
        {            
            for(int roll = 0; roll < 4; roll++)
            {
                rolls[roll] = 1 + (rand() % 6);
            }
            
            sort(rolls, rolls + 4);
            int roll_total = rolls[1] + rolls[2] + rolls[3];            
                        
            attributes[attrib] = roll_total;
            attributes_total += roll_total;
            
            if(roll_total >= 15) count++;
        }
    }
    
    cout << "Attributes generated : [";
    cout << attributes[0] << ", ";
    cout << attributes[1] << ", ";
    cout << attributes[2] << ", ";
    cout << attributes[3] << ", ";
    cout << attributes[4] << ", ";
    cout << attributes[5];
    
    cout << "]\nTotal: " << attributes_total;
    cout << ", Values above 15 : " << count;
    
    return 0;
}

Python: import random
random.seed()
attributes_total = 0
count = 0

while attributes_total < 75 or count < 2:
    attributes = []

    for attribute in range(0, 6):
        rolls = []
        
        for roll in range(0, 4):
            result = random.randint(1, 6)
            rolls.append(result)
        
        sorted_rolls = sorted(rolls)
        largest_3 = sorted_rolls[1:]
        rolls_total = sum(largest_3)
        
        if rolls_total >= 15:
            count += 1
        
        attributes.append(rolls_total)

    attributes_total = sum(attributes)
    
print(attributes_total, attributes)
Task: RPG attributes generator
C#: using System;
using System.Collections.Generic;
using System.Linq;

static class Module1
{
    static Random r = new Random();

    static List<int> getThree(int n)
    {
        List<int> g3 = new List<int>();
        for (int i = 0; i < 4; i++) g3.Add(r.Next(n) + 1);
        g3.Sort(); g3.RemoveAt(0); return g3;
    }

    static List<int> getSix()
    {
        List<int> g6 = new List<int>();
        for (int i = 0; i < 6; i++) g6.Add(getThree(6).Sum());
        return g6;
    }

    static void Main(string[] args)
    {
        bool good = false; do {
            List<int> gs = getSix(); int gss = gs.Sum(); int hvc = gs.FindAll(x => x > 14).Count;
            Console.Write("attribs: {0}, sum={1}, ({2} sum, high vals={3})",
                          string.Join(", ", gs), gss, gss >= 75 ? "good" : "low", hvc);
            Console.WriteLine(" - {0}", (good = gs.Sum() >= 75 && hvc > 1) ? "success" : "failure");
        } while (!good);
    }
}

Go: package main

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

func main() {
    s := rand.NewSource(time.Now().UnixNano())
    r := rand.New(s)
    for {
        var values [6]int
        vsum := 0
        for i := range values {
            var numbers [4]int
            for j := range numbers {
                numbers[j] = 1 + r.Intn(6)
            }
            sort.Ints(numbers[:])
            nsum := 0
            for _, n := range numbers[1:] {
                nsum += n
            }
            values[i] = nsum
            vsum += values[i]
        }
        if vsum < 75 {
            continue
        }
        vcount := 0
        for _, v := range values {
            if v >= 15 {
                vcount++
            }
        }
        if vcount < 2 {
            continue
        }
        fmt.Println("The 6 random numbers generated are:")
        fmt.Println(values)
        fmt.Println("\nTheir sum is", vsum, "and", vcount, "of them are >= 15")
        break
    }
}
Task: RPG attributes generator
C#: using System;
using System.Collections.Generic;
using System.Linq;

static class Module1
{
    static Random r = new Random();

    static List<int> getThree(int n)
    {
        List<int> g3 = new List<int>();
        for (int i = 0; i < 4; i++) g3.Add(r.Next(n) + 1);
        g3.Sort(); g3.RemoveAt(0); return g3;
    }

    static List<int> getSix()
    {
        List<int> g6 = new List<int>();
        for (int i = 0; i < 6; i++) g6.Add(getThree(6).Sum());
        return g6;
    }

    static void Main(string[] args)
    {
        bool good = false; do {
            List<int> gs = getSix(); int gss = gs.Sum(); int hvc = gs.FindAll(x => x > 14).Count;
            Console.Write("attribs: {0}, sum={1}, ({2} sum, high vals={3})",
                          string.Join(", ", gs), gss, gss >= 75 ? "good" : "low", hvc);
            Console.WriteLine(" - {0}", (good = gs.Sum() >= 75 && hvc > 1) ? "success" : "failure");
        } while (!good);
    }
}

Java: import java.util.List;
import java.util.Random;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toList;

public class Rpg {

    private static final Random random = new Random();
 
    public static int genAttribute() {
        return random.ints(1, 6 + 1) 
            .limit(4) 
            .sorted() 
            .limit(3) 
            .sum();   
    }
 
    public static void main(String[] args) {
        while (true) {
            List<Integer> stats =
                Stream.generate(Rpg::genAttribute) 
                    .limit(6) 
                    .collect(toList()); 
            int sum = stats.stream().mapToInt(Integer::intValue).sum();
            long count = stats.stream().filter(v -> v >= 15).count();
            if (count >= 2 && sum >= 75) {
                System.out.printf("The 6 random numbers generated are: %s\n", stats);
                System.out.printf("Their sum is %s and %s of them are >= 15\n", sum, count);
                return;
            }      
        }
    }
}