kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Implicit type conversion
C#: byte aByte = 2;
short aShort = aByte;
int anInt = aShort;
long aLong = anInt;

float aFloat = 1.2f;
double aDouble = aFloat;

BigInteger b = 5;
Complex c = 2.5; 

Python: from fractions import Fraction
from decimal import Decimal, getcontext
getcontext().prec = 60
from itertools import product

casting_functions = [int, float, complex,   
                     Fraction, Decimal,     
                     hex, oct, bin,         
                     bool,                  
                     iter,                  
                     list, tuple, range,    
                     str, bytes,            
                     bytearray,             
                     set, frozenset,        
                     dict,                  
                    ]

examples_of_types = [0, 42, 
                     0.0 -0.0, 12.34, 56.0, 
                     (0+0j), (1+2j), (1+0j), (78.9+0j), (0+1.2j),
                     Fraction(0, 1), Fraction(22, 7), Fraction(4, 2), 
                     Decimal('0'),
                     Decimal('3.14159265358979323846264338327950288419716939937510'),
                     Decimal('1'), Decimal('1.5'),
                     True, False,
                     iter(()), iter([1, 2, 3]), iter({'A', 'B', 'C'}), 
                     iter([[1, 2], [3, 4]]), iter((('a', 1), (2, 'b'))),
                     [], [1, 2], [[1, 2], [3, 4]],
                     (), (1, 'two', (3+0j)), (('a', 1), (2, 'b')),
                     range(0), range(3),
                     "", "A", "ABBA", "Milü",
                     b"", b"A", b"ABBA",
                     bytearray(b""), bytearray(b"A"), bytearray(b"ABBA"),
                     set(), {1, 'two', (3+0j), (4, 5, 6)},
                     frozenset(), frozenset({1, 'two', (3+0j), (4, 5, 6)}),
                     {}, {1: 'one', 'two': (2+3j), ('RC', 3): None} 
                    ]
if __name__ == '__main__':
    print('Common Python types/type casting functions:')
    print('  ' + '\n  '.join(f.__name__ for f in casting_functions))
    print('\nExamples of those types:')
    print('  ' + '\n  '.join('%-26s %r' % (type(e), e) for e in examples_of_types))
    print('\nCasts of the examples:')
    for f, e in product(casting_functions, examples_of_types):
        try:
            ans = f(e)
        except BaseException:
            ans = 'EXCEPTION RAISED!'
        print('%-60s -> %r' % ('%s(%r)' % (f.__name__, e), ans))
Task: Implicit type conversion
Go: package main

import "fmt"

func main() {
    

    
    
    var i int32 = 1
    fmt.Printf("i : type %-7T value %d\n", i, i)

    
    
    
    j := 2
    fmt.Printf("j : type %-7T value %d\n", j, j)

    
    
    
    
    var k int64 = int64(i) + int64(j)
    fmt.Printf("k : type %-7T value %d\n", k, k)

    
    
    

    
    
    
    var l int8 = 4.0
    fmt.Printf("l : type %-7T value %d\n", l, l)

    
    
    
    m := 0.3 + float64(l) + 0.7
    fmt.Printf("m : type %-7T value %g\n", m, m)
}

Java: public class ImplicitTypeConversion{
   public static void main(String...args){
      System.out.println( "Primitive conversions" );
      byte  by = -1;
      short sh = by;
      int   in = sh;
      long  lo = in;
      System.out.println( "byte value    -1         to 3 integral types:  " + lo );

      float  fl = 0.1f;
      double db = fl;
      System.out.println( "float value   0.1        to double:            " + db );

      int    in2 = -1;
      float  fl2 = in2;
      double db2 = fl2;
      System.out.println( "int value     -1         to float and double:  " + db2 );

      int    in3 = Integer.MAX_VALUE;
      float  fl3 = in3;
      double db3 = fl3;
      System.out.println( "int value     " + Integer.MAX_VALUE + " to float and double:  " + db3 );

      char   ch  = 'a';
      int    in4 = ch;
      double db4 = in4;
      System.out.println( "char value    '" + ch + "'        to int and double:    " + db4 );

      System.out.println();
      System.out.println( "Boxing and unboxing" );
      Integer in5 = -1;
      int     in6 = in5;
      System.out.println( "int  value    -1         to Integer and int:   " + in6 );

      Double db5 = 0.1;
      double db6 = db5;
      System.out.println( "double value  0.1        to Double and double: " + db6 );
   }
}
Task: Implicit type conversion
Go: package main

import "fmt"

func main() {
    

    
    
    var i int32 = 1
    fmt.Printf("i : type %-7T value %d\n", i, i)

    
    
    
    j := 2
    fmt.Printf("j : type %-7T value %d\n", j, j)

    
    
    
    
    var k int64 = int64(i) + int64(j)
    fmt.Printf("k : type %-7T value %d\n", k, k)

    
    
    

    
    
    
    var l int8 = 4.0
    fmt.Printf("l : type %-7T value %d\n", l, l)

    
    
    
    m := 0.3 + float64(l) + 0.7
    fmt.Printf("m : type %-7T value %g\n", m, m)
}

Python: from fractions import Fraction
from decimal import Decimal, getcontext
getcontext().prec = 60
from itertools import product

casting_functions = [int, float, complex,   
                     Fraction, Decimal,     
                     hex, oct, bin,         
                     bool,                  
                     iter,                  
                     list, tuple, range,    
                     str, bytes,            
                     bytearray,             
                     set, frozenset,        
                     dict,                  
                    ]

examples_of_types = [0, 42, 
                     0.0 -0.0, 12.34, 56.0, 
                     (0+0j), (1+2j), (1+0j), (78.9+0j), (0+1.2j),
                     Fraction(0, 1), Fraction(22, 7), Fraction(4, 2), 
                     Decimal('0'),
                     Decimal('3.14159265358979323846264338327950288419716939937510'),
                     Decimal('1'), Decimal('1.5'),
                     True, False,
                     iter(()), iter([1, 2, 3]), iter({'A', 'B', 'C'}), 
                     iter([[1, 2], [3, 4]]), iter((('a', 1), (2, 'b'))),
                     [], [1, 2], [[1, 2], [3, 4]],
                     (), (1, 'two', (3+0j)), (('a', 1), (2, 'b')),
                     range(0), range(3),
                     "", "A", "ABBA", "Milü",
                     b"", b"A", b"ABBA",
                     bytearray(b""), bytearray(b"A"), bytearray(b"ABBA"),
                     set(), {1, 'two', (3+0j), (4, 5, 6)},
                     frozenset(), frozenset({1, 'two', (3+0j), (4, 5, 6)}),
                     {}, {1: 'one', 'two': (2+3j), ('RC', 3): None} 
                    ]
if __name__ == '__main__':
    print('Common Python types/type casting functions:')
    print('  ' + '\n  '.join(f.__name__ for f in casting_functions))
    print('\nExamples of those types:')
    print('  ' + '\n  '.join('%-26s %r' % (type(e), e) for e in examples_of_types))
    print('\nCasts of the examples:')
    for f, e in product(casting_functions, examples_of_types):
        try:
            ans = f(e)
        except BaseException:
            ans = 'EXCEPTION RAISED!'
        print('%-60s -> %r' % ('%s(%r)' % (f.__name__, e), ans))
Task: Strange plus numbers
C: #include <stdio.h>

static int p[19] = {0, 0, 1, 1, 0, 1, 0, 1, 0, 0,
                    0, 1, 0, 1, 0, 0, 0, 1, 0};

int isstrange(long n) {
    if (n < 10) return 0;
    for (; n >= 10; n /= 10) {
        if (!p[n%10 + (n/10)%10]) return 0;
    }
    return 1;
}

int main(void) {
    long n;
    int k = 0;

    for (n = 101; n < 500; n++) {
        if (isstrange(n)) {
            printf("%d%c", n, ++k%10 ? ' ' : '\n');
        }
    }
    return 0;
}

Java: public class Strange {
    private static final boolean[] p = {
        false, false, true,  true,  false,
        true,  false, true,  false, false,
        false, true,  false, true,  false,
        false, false, true,  false
    };

    public static boolean isstrange(long n) {
        if (n < 10) return false;
        for (; n >= 10; n /= 10) {
            if (!p[(int)(n%10 + (n/10)%10)]) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        long nMin = Long.parseLong(args[0]);
        long nMax = Long.parseLong(args[1]);
        int k = 0;
     
        for (long n = nMin; n <= nMax; n++) {
            if (isstrange(n)) {
                System.out.print(n + (++k%10 != 0 ? " " : "\n"));
            }
        }
    }
}
Task: Strange plus numbers
C: #include <stdio.h>

static int p[19] = {0, 0, 1, 1, 0, 1, 0, 1, 0, 0,
                    0, 1, 0, 1, 0, 0, 0, 1, 0};

int isstrange(long n) {
    if (n < 10) return 0;
    for (; n >= 10; n /= 10) {
        if (!p[n%10 + (n/10)%10]) return 0;
    }
    return 1;
}

int main(void) {
    long n;
    int k = 0;

    for (n = 101; n < 500; n++) {
        if (isstrange(n)) {
            printf("%d%c", n, ++k%10 ? ' ' : '\n');
        }
    }
    return 0;
}

Python: Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> from sympy import isprime

>>> [x for x in range(101,500) 
 if isprime(sum(int(c) for c in str(x)[:2])) and
    isprime(sum(int(c) for c in str(x)[1:]))]
[111, 112, 114, 116, 120, 121, 123, 125, 129, 141, 143, 147, 149, 161, 165, 167, 202, 203, 205, 207, 211, 212, 214, 216, 230, 232, 234, 238, 250, 252, 256, 258, 292, 294, 298, 302, 303, 305, 307, 320, 321, 323, 325, 329, 341, 343, 347, 349, 383, 385, 389, 411, 412, 414, 416, 430, 432, 434, 438, 470, 474, 476, 492, 494, 498]
>>>
Task: Strange plus numbers
Go: package main

import "fmt"

func isPrime(n int) bool {
    return n == 2 || n == 3 || n == 5 || n == 7 || n == 11 || n == 13 || n == 17
}

func main() {
    count := 0
    var d []int
    fmt.Println("Strange plus numbers in the open interval (100, 500) are:\n")
    for i := 101; i < 500; i++ {
        d = d[:0]
        j := i
        for j > 0 {
            d = append(d, j%10)
            j /= 10
        }
        if isPrime(d[0]+d[1]) && isPrime(d[1]+d[2]) {
            fmt.Printf("%d ", i)
            count++
            if count%10 == 0 {
                fmt.Println()
            }
        }
    }
    if count%10 != 0 {
        fmt.Println()
    }
    fmt.Printf("\n%d strange plus numbers in all.\n", count)
}

Java: public class Strange {
    private static final boolean[] p = {
        false, false, true,  true,  false,
        true,  false, true,  false, false,
        false, true,  false, true,  false,
        false, false, true,  false
    };

    public static boolean isstrange(long n) {
        if (n < 10) return false;
        for (; n >= 10; n /= 10) {
            if (!p[(int)(n%10 + (n/10)%10)]) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        long nMin = Long.parseLong(args[0]);
        long nMax = Long.parseLong(args[1]);
        int k = 0;
     
        for (long n = nMin; n <= nMax; n++) {
            if (isstrange(n)) {
                System.out.print(n + (++k%10 != 0 ? " " : "\n"));
            }
        }
    }
}
Task: Strange plus numbers
Java: public class Strange {
    private static final boolean[] p = {
        false, false, true,  true,  false,
        true,  false, true,  false, false,
        false, true,  false, true,  false,
        false, false, true,  false
    };

    public static boolean isstrange(long n) {
        if (n < 10) return false;
        for (; n >= 10; n /= 10) {
            if (!p[(int)(n%10 + (n/10)%10)]) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        long nMin = Long.parseLong(args[0]);
        long nMax = Long.parseLong(args[1]);
        int k = 0;
     
        for (long n = nMin; n <= nMax; n++) {
            if (isstrange(n)) {
                System.out.print(n + (++k%10 != 0 ? " " : "\n"));
            }
        }
    }
}

Python: Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> from sympy import isprime

>>> [x for x in range(101,500) 
 if isprime(sum(int(c) for c in str(x)[:2])) and
    isprime(sum(int(c) for c in str(x)[1:]))]
[111, 112, 114, 116, 120, 121, 123, 125, 129, 141, 143, 147, 149, 161, 165, 167, 202, 203, 205, 207, 211, 212, 214, 216, 230, 232, 234, 238, 250, 252, 256, 258, 292, 294, 298, 302, 303, 305, 307, 320, 321, 323, 325, 329, 341, 343, 347, 349, 383, 385, 389, 411, 412, 414, 416, 430, 432, 434, 438, 470, 474, 476, 492, 494, 498]
>>>
Task: Strange plus numbers
Go: package main

import "fmt"

func isPrime(n int) bool {
    return n == 2 || n == 3 || n == 5 || n == 7 || n == 11 || n == 13 || n == 17
}

func main() {
    count := 0
    var d []int
    fmt.Println("Strange plus numbers in the open interval (100, 500) are:\n")
    for i := 101; i < 500; i++ {
        d = d[:0]
        j := i
        for j > 0 {
            d = append(d, j%10)
            j /= 10
        }
        if isPrime(d[0]+d[1]) && isPrime(d[1]+d[2]) {
            fmt.Printf("%d ", i)
            count++
            if count%10 == 0 {
                fmt.Println()
            }
        }
    }
    if count%10 != 0 {
        fmt.Println()
    }
    fmt.Printf("\n%d strange plus numbers in all.\n", count)
}

Python: Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> from sympy import isprime

>>> [x for x in range(101,500) 
 if isprime(sum(int(c) for c in str(x)[:2])) and
    isprime(sum(int(c) for c in str(x)[1:]))]
[111, 112, 114, 116, 120, 121, 123, 125, 129, 141, 143, 147, 149, 161, 165, 167, 202, 203, 205, 207, 211, 212, 214, 216, 230, 232, 234, 238, 250, 252, 256, 258, 292, 294, 298, 302, 303, 305, 307, 320, 321, 323, 325, 329, 341, 343, 347, 349, 383, 385, 389, 411, 412, 414, 416, 430, 432, 434, 438, 470, 474, 476, 492, 494, 498]
>>>
Task: Strange plus numbers
C: #include <stdio.h>

static int p[19] = {0, 0, 1, 1, 0, 1, 0, 1, 0, 0,
                    0, 1, 0, 1, 0, 0, 0, 1, 0};

int isstrange(long n) {
    if (n < 10) return 0;
    for (; n >= 10; n /= 10) {
        if (!p[n%10 + (n/10)%10]) return 0;
    }
    return 1;
}

int main(void) {
    long n;
    int k = 0;

    for (n = 101; n < 500; n++) {
        if (isstrange(n)) {
            printf("%d%c", n, ++k%10 ? ' ' : '\n');
        }
    }
    return 0;
}

Go: package main

import "fmt"

func isPrime(n int) bool {
    return n == 2 || n == 3 || n == 5 || n == 7 || n == 11 || n == 13 || n == 17
}

func main() {
    count := 0
    var d []int
    fmt.Println("Strange plus numbers in the open interval (100, 500) are:\n")
    for i := 101; i < 500; i++ {
        d = d[:0]
        j := i
        for j > 0 {
            d = append(d, j%10)
            j /= 10
        }
        if isPrime(d[0]+d[1]) && isPrime(d[1]+d[2]) {
            fmt.Printf("%d ", i)
            count++
            if count%10 == 0 {
                fmt.Println()
            }
        }
    }
    if count%10 != 0 {
        fmt.Println()
    }
    fmt.Printf("\n%d strange plus numbers in all.\n", count)
}
Task: Hilbert curve
C: #include <stdio.h>

#define N 32
#define K 3
#define MAX N * K

typedef struct { int x; int y; } point;

void rot(int n, point *p, int rx, int ry) {
    int t;
    if (!ry) {
        if (rx == 1) {
            p->x = n - 1 - p->x;
            p->y = n - 1 - p->y;
        }
        t = p->x;
        p->x = p->y;
        p->y = t;
    }
}

void d2pt(int n, int d, point *p) {
    int s = 1, t = d, rx, ry;
    p->x = 0;
    p->y = 0;
    while (s < n) {
        rx = 1 & (t / 2);
        ry = 1 & (t ^ rx);
        rot(s, p, rx, ry);
        p->x += s * rx;
        p->y += s * ry;
        t /= 4;
        s *= 2;
    }
}

int main() {
    int d, x, y, cx, cy, px, py;
    char pts[MAX][MAX];
    point curr, prev;
    for (x = 0; x < MAX; ++x)
        for (y = 0; y < MAX; ++y) pts[x][y] = ' ';
    prev.x = prev.y = 0;
    pts[0][0] = '.';
    for (d = 1; d < N * N; ++d) {
        d2pt(N, d, &curr);
        cx = curr.x * K;
        cy = curr.y * K;
        px = prev.x * K;
        py = prev.y * K;
        pts[cx][cy] = '.';
        if (cx == px ) {
            if (py < cy)
                for (y = py + 1; y < cy; ++y) pts[cx][y] = '|';
            else
                for (y = cy + 1; y < py; ++y) pts[cx][y] = '|';
        }
        else {
            if (px < cx)
                for (x = px + 1; x < cx; ++x) pts[x][cy] = '_';
            else
                for (x = cx + 1; x < px; ++x) pts[x][cy] = '_';
        }
        prev = curr;
    }
    for (x = 0; x < MAX; ++x) {
        for (y = 0; y < MAX; ++y) printf("%c", pts[y][x]);
        printf("\n");
    }
    return 0;
}

Go: package main

import "github.com/fogleman/gg"

var points []gg.Point

const width = 64

func hilbert(x, y, lg, i1, i2 int) {
    if lg == 1 {
        px := float64(width-x) * 10
        py := float64(width-y) * 10
        points = append(points, gg.Point{px, py})
        return
    }
    lg >>= 1
    hilbert(x+i1*lg, y+i1*lg, lg, i1, 1-i2)
    hilbert(x+i2*lg, y+(1-i2)*lg, lg, i1, i2)
    hilbert(x+(1-i1)*lg, y+(1-i1)*lg, lg, i1, i2)
    hilbert(x+(1-i2)*lg, y+i2*lg, lg, 1-i1, i2)
}

func main() {
    hilbert(0, 0, width, 0, 0)
    dc := gg.NewContext(650, 650)
    dc.SetRGB(0, 0, 0) 
    dc.Clear()
    for _, p := range points {
        dc.LineTo(p.X, p.Y)
    }
    dc.SetHexColor("#90EE90") 
    dc.SetLineWidth(1)
    dc.Stroke()
    dc.SavePNG("hilbert.png")
}
Task: Hilbert curve
C: #include <stdio.h>

#define N 32
#define K 3
#define MAX N * K

typedef struct { int x; int y; } point;

void rot(int n, point *p, int rx, int ry) {
    int t;
    if (!ry) {
        if (rx == 1) {
            p->x = n - 1 - p->x;
            p->y = n - 1 - p->y;
        }
        t = p->x;
        p->x = p->y;
        p->y = t;
    }
}

void d2pt(int n, int d, point *p) {
    int s = 1, t = d, rx, ry;
    p->x = 0;
    p->y = 0;
    while (s < n) {
        rx = 1 & (t / 2);
        ry = 1 & (t ^ rx);
        rot(s, p, rx, ry);
        p->x += s * rx;
        p->y += s * ry;
        t /= 4;
        s *= 2;
    }
}

int main() {
    int d, x, y, cx, cy, px, py;
    char pts[MAX][MAX];
    point curr, prev;
    for (x = 0; x < MAX; ++x)
        for (y = 0; y < MAX; ++y) pts[x][y] = ' ';
    prev.x = prev.y = 0;
    pts[0][0] = '.';
    for (d = 1; d < N * N; ++d) {
        d2pt(N, d, &curr);
        cx = curr.x * K;
        cy = curr.y * K;
        px = prev.x * K;
        py = prev.y * K;
        pts[cx][cy] = '.';
        if (cx == px ) {
            if (py < cy)
                for (y = py + 1; y < cy; ++y) pts[cx][y] = '|';
            else
                for (y = cy + 1; y < py; ++y) pts[cx][y] = '|';
        }
        else {
            if (px < cx)
                for (x = px + 1; x < cx; ++x) pts[x][cy] = '_';
            else
                for (x = cx + 1; x < px; ++x) pts[x][cy] = '_';
        }
        prev = curr;
    }
    for (x = 0; x < MAX; ++x) {
        for (y = 0; y < MAX; ++y) printf("%c", pts[y][x]);
        printf("\n");
    }
    return 0;
}

Python: iterations = 7
stroke_len = 600
angle_deg = 90
axiom = 'L'
sentence = axiom
rules = {
    'L': '+RF-LFL-FR+',
    'R': '-LF+RFR+FL-',
}

def setup():
    size(700, 700)
    global xo, yo
    xo, yo = 50, height - 50
    strokeWeight(1)
    noFill()
    generate(iterations)

def draw():
    background(0)
    translate(xo, yo)
    plot(radians(angle_deg))

def generate(n):
    global stroke_len, sentence
    for _ in range(n):
        stroke_len *= 0.5
        next_sentence = ''
        for c in sentence:
            next_sentence += rules.get(c, c)
        sentence = next_sentence

def plot(angle):
    for c in sentence:
        if c == 'F':
            stroke(255)
            line(0, 0, 0, -stroke_len)
            translate(0, -stroke_len)
        elif c == '+':
            rotate(angle)
        elif c == '-':
            rotate(-angle)

def keyPressed():
    global angle_deg, xo, yo, stroke_len
    if key == '-':
        angle_deg -= 5
        print(angle_deg)
    if str(key) in "=+":
        angle_deg += 5
        print(angle_deg)
    if key == 'a':
        stroke_len *= 2
    if key == 'z':
        stroke_len /= 2
    if keyCode == LEFT:
        xo -= 50
    if keyCode == RIGHT:
        xo += 50
    if keyCode == UP:
        yo -= 50
    if keyCode == DOWN:
        yo += 50
Task: Hilbert curve
C++: #include <algorithm>
#include <iostream>
#include <vector>

struct Point {
    int x, y;

    
    void rot(int n, bool rx, bool ry) {
        if (!ry) {
            if (rx) {
                x = (n - 1) - x;
                y = (n - 1) - y;
            }
            std::swap(x, y);
        }
    }
};

Point fromD(int n, int d) {
    Point p = { 0, 0 };
    bool rx, ry;
    int t = d;
    for (int s = 1; s < n; s <<= 1) {
        rx = ((t & 2) != 0);
        ry = (((t ^ (rx ? 1 : 0)) & 1) != 0);
        p.rot(s, rx, ry);
        p.x += (rx ? s : 0);
        p.y += (ry ? s : 0);
        t >>= 2;
    }
    return p;
}

std::vector<Point> getPointsForCurve(int n) {
    std::vector<Point> points;
    for (int d = 0; d < n * n; ++d) {
        points.push_back(fromD(n, d));
    }
    return points;
}

std::vector<std::string> drawCurve(const std::vector<Point> &points, int n) {
    auto canvas = new char *[n];
    for (size_t i = 0; i < n; i++) {
        canvas[i] = new char[n * 3 - 2];
        std::memset(canvas[i], ' ', n * 3 - 2);
    }

    for (int i = 1; i < points.size(); i++) {
        auto lastPoint = points[i - 1];
        auto curPoint = points[i];
        int deltaX = curPoint.x - lastPoint.x;
        int deltaY = curPoint.y - lastPoint.y;
        if (deltaX == 0) {
            
            int row = std::max(curPoint.y, lastPoint.y);
            int col = curPoint.x * 3;
            canvas[row][col] = '|';
        } else {
            
            int row = curPoint.y;
            int col = std::min(curPoint.x, lastPoint.x) * 3 + 1;
            canvas[row][col] = '_';
            canvas[row][col + 1] = '_';
        }
    }

    std::vector<std::string> lines;
    for (size_t i = 0; i < n; i++) {
        std::string temp;
        temp.assign(canvas[i], n * 3 - 2);
        lines.push_back(temp);
    }
    return lines;
}

int main() {
    for (int order = 1; order < 6; order++) {
        int n = 1 << order;
        auto points = getPointsForCurve(n);
        std::cout << "Hilbert curve, order=" << order << '\n';
        auto lines = drawCurve(points, n);
        for (auto &line : lines) {
            std::cout << line << '\n';
        }
        std::cout << '\n';
    }
    return 0;
}

Go: package main

import "github.com/fogleman/gg"

var points []gg.Point

const width = 64

func hilbert(x, y, lg, i1, i2 int) {
    if lg == 1 {
        px := float64(width-x) * 10
        py := float64(width-y) * 10
        points = append(points, gg.Point{px, py})
        return
    }
    lg >>= 1
    hilbert(x+i1*lg, y+i1*lg, lg, i1, 1-i2)
    hilbert(x+i2*lg, y+(1-i2)*lg, lg, i1, i2)
    hilbert(x+(1-i1)*lg, y+(1-i1)*lg, lg, i1, i2)
    hilbert(x+(1-i2)*lg, y+i2*lg, lg, 1-i1, i2)
}

func main() {
    hilbert(0, 0, width, 0, 0)
    dc := gg.NewContext(650, 650)
    dc.SetRGB(0, 0, 0) 
    dc.Clear()
    for _, p := range points {
        dc.LineTo(p.X, p.Y)
    }
    dc.SetHexColor("#90EE90") 
    dc.SetLineWidth(1)
    dc.Stroke()
    dc.SavePNG("hilbert.png")
}