WeixiangYan/CodeTransOcean huggingface dataset:
Task: Birthday problem





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

public class Test {

    static double equalBirthdays(int nSharers, int groupSize, int nRepetitions) {
        Random rand = new Random(1);

        int eq = 0;

        for (int i = 0; i < nRepetitions; i++) {
            int[] group = new int[365];
            for (int j = 0; j < groupSize; j++)
                group[rand.nextInt(group.length)]++;
            eq += stream(group).anyMatch(c -> c >= nSharers) ? 1 : 0;
        }

        return (eq * 100.0) / nRepetitions;
    }

    public static void main(String[] a) {

        int groupEst = 2;

        for (int sharers = 2; sharers < 6; sharers++) {
            
            int groupSize = groupEst + 1;
            while (equalBirthdays(sharers, groupSize, 100) < 50.0)
                groupSize++;

            
            int inf = (int) (groupSize - (groupSize - groupEst) / 4.0);
            for (int gs = inf; gs < groupSize + 999; gs++) {
                double eq = equalBirthdays(sharers, groupSize, 250);
                if (eq > 50.0) {
                    groupSize = gs;
                    break;
                }
            }

            
            for (int gs = groupSize - 1; gs < groupSize + 999; gs++) {
                double eq = equalBirthdays(sharers, gs, 50_000);
                if (eq > 50.0) {
                    groupEst = gs;
                    System.out.printf("%d independent people in a group of "
                            + "%s share a common birthday. (%5.1f)%n",
                            sharers, gs, eq);
                    break;
                }
            }
        }
    }
}



Python: from random import randint

def equal_birthdays(sharers=2, groupsize=23, rep=100000):
    'Note: 4 sharing common birthday may have 2 dates shared between two people each' 
    g = range(groupsize)
    sh = sharers - 1
    eq = sum((groupsize - len(set(randint(1,365) for i in g)) >= sh)
             for j in range(rep))
    return (eq * 100.) / rep

def equal_birthdays(sharers=2, groupsize=23, rep=100000):
    'Note: 4 sharing common birthday must all share same common day' 
    g = range(groupsize)
    sh = sharers - 1
    eq = 0
    for j in range(rep):
        group = [randint(1,365) for i in g]
        if (groupsize - len(set(group)) >= sh and
            any( group.count(member) >= sharers for member in set(group))):
            eq += 1
    return (eq * 100.) / rep

group_est = [2]
for sharers in (2, 3, 4, 5):
    groupsize = group_est[-1]+1
    while equal_birthdays(sharers, groupsize, 100) < 50.:
        
        groupsize += 1
    for groupsize in range(int(groupsize - (groupsize - group_est[-1])/4.), groupsize + 999):
        
        eq = equal_birthdays(sharers, groupsize, 250)
        if eq > 50.:
            break
    for groupsize in range(groupsize - 1, groupsize +999):
        
        eq = equal_birthdays(sharers, groupsize, 50000)
        if eq > 50.:
            break
    group_est.append(groupsize)
    print("%i independent people in a group of %s share a common birthday. (%5.1f)" % (sharers, groupsize, eq))
Task: Non-decimal radices_Input

C: #include <stdio.h>

int main()
{
  int num;

  sscanf("0123459", "%d", &num);
  printf("%d\n", num); 

  sscanf("abcf123", "%x", &num);
  printf("%d\n", num); 

  sscanf("7651", "%o", &num);
  printf("%d\n", num); 

  

  return 0;
}



C#: using System;

class Program
{
    static void Main()
    {
        var value = "100";
        var fromBases = new[] { 2, 8, 10, 16 };
        var toBase = 10;
        foreach (var fromBase in fromBases)
        {
            Console.WriteLine("{0} in base {1} is {2} in base {3}",
                value, fromBase, Convert.ToInt32(value, fromBase), toBase);
        }
    }
}
Task: Non-decimal radices_Input

C: #include <stdio.h>

int main()
{
  int num;

  sscanf("0123459", "%d", &num);
  printf("%d\n", num); 

  sscanf("abcf123", "%x", &num);
  printf("%d\n", num); 

  sscanf("7651", "%o", &num);
  printf("%d\n", num); 

  

  return 0;
}


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

int main()
{
  int num;

  std::istringstream("0123459") >> num;
  std::cout << num << std::endl; 

  std::istringstream("0123459") >> std::dec >> num;
  std::cout << num << std::endl; 

  std::istringstream("abcf123") >> std::hex >> num;
  std::cout << num << std::endl; 

  std::istringstream("7651") >> std::oct >> num;
  std::cout << num << std::endl; 

  

  return 0;
}
Task: Non-decimal radices_Input

C: #include <stdio.h>

int main()
{
  int num;

  sscanf("0123459", "%d", &num);
  printf("%d\n", num); 

  sscanf("abcf123", "%x", &num);
  printf("%d\n", num); 

  sscanf("7651", "%o", &num);
  printf("%d\n", num); 

  

  return 0;
}




Go: package main

import (
    "fmt"
    "math/big"
    "strconv"
)

func main() {
    
    
    x, _ := strconv.Atoi("13")
    fmt.Println(x)

    
    
    
    
    x64, _ := strconv.ParseInt("3c2", 19, 64)
    fmt.Println(x64)

    
    
    
    
    
    
    fmt.Sscanf("1101", "%b", &x)
    fmt.Println(x)

    fmt.Sscanf("15", "%o", &x)
    fmt.Println(x)

    fmt.Sscanf("13", "%d", &x)
    fmt.Println(x)

    fmt.Sscanf("d", "%x", &x)
    fmt.Println(x)

    
    
    var z big.Int
    z.SetString("111", 3)
    fmt.Println(&z)

    
    z.SetString("0b1101", 0) 
    fmt.Println(&z)

    z.SetString("015", 0) 
    fmt.Println(&z)

    z.SetString("13", 0) 
    fmt.Println(&z)

    z.SetString("0xd", 0) 
    fmt.Println(&z)

    
    
    fmt.Sscanf("15", "%o", &z)
    fmt.Println(&z)
}
Task: Non-decimal radices_Input


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

int main()
{
  int num;

  std::istringstream("0123459") >> num;
  std::cout << num << std::endl; 

  std::istringstream("0123459") >> std::dec >> num;
  std::cout << num << std::endl; 

  std::istringstream("abcf123") >> std::hex >> num;
  std::cout << num << std::endl; 

  std::istringstream("7651") >> std::oct >> num;
  std::cout << num << std::endl; 

  

  return 0;
}


C#: using System;

class Program
{
    static void Main()
    {
        var value = "100";
        var fromBases = new[] { 2, 8, 10, 16 };
        var toBase = 10;
        foreach (var fromBase in fromBases)
        {
            Console.WriteLine("{0} in base {1} is {2} in base {3}",
                value, fromBase, Convert.ToInt32(value, fromBase), toBase);
        }
    }
}
Task: Non-decimal radices_Input


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

int main()
{
  int num;

  std::istringstream("0123459") >> num;
  std::cout << num << std::endl; 

  std::istringstream("0123459") >> std::dec >> num;
  std::cout << num << std::endl; 

  std::istringstream("abcf123") >> std::hex >> num;
  std::cout << num << std::endl; 

  std::istringstream("7651") >> std::oct >> num;
  std::cout << num << std::endl; 

  

  return 0;
}



Go: package main

import (
    "fmt"
    "math/big"
    "strconv"
)

func main() {
    
    
    x, _ := strconv.Atoi("13")
    fmt.Println(x)

    
    
    
    
    x64, _ := strconv.ParseInt("3c2", 19, 64)
    fmt.Println(x64)

    
    
    
    
    
    
    fmt.Sscanf("1101", "%b", &x)
    fmt.Println(x)

    fmt.Sscanf("15", "%o", &x)
    fmt.Println(x)

    fmt.Sscanf("13", "%d", &x)
    fmt.Println(x)

    fmt.Sscanf("d", "%x", &x)
    fmt.Println(x)

    
    
    var z big.Int
    z.SetString("111", 3)
    fmt.Println(&z)

    
    z.SetString("0b1101", 0) 
    fmt.Println(&z)

    z.SetString("015", 0) 
    fmt.Println(&z)

    z.SetString("13", 0) 
    fmt.Println(&z)

    z.SetString("0xd", 0) 
    fmt.Println(&z)

    
    
    fmt.Sscanf("15", "%o", &z)
    fmt.Println(&z)
}
Task: Non-decimal radices_Input



C#: using System;

class Program
{
    static void Main()
    {
        var value = "100";
        var fromBases = new[] { 2, 8, 10, 16 };
        var toBase = 10;
        foreach (var fromBase in fromBases)
        {
            Console.WriteLine("{0} in base {1} is {2} in base {3}",
                value, fromBase, Convert.ToInt32(value, fromBase), toBase);
        }
    }
}


Go: package main

import (
    "fmt"
    "math/big"
    "strconv"
)

func main() {
    
    
    x, _ := strconv.Atoi("13")
    fmt.Println(x)

    
    
    
    
    x64, _ := strconv.ParseInt("3c2", 19, 64)
    fmt.Println(x64)

    
    
    
    
    
    
    fmt.Sscanf("1101", "%b", &x)
    fmt.Println(x)

    fmt.Sscanf("15", "%o", &x)
    fmt.Println(x)

    fmt.Sscanf("13", "%d", &x)
    fmt.Println(x)

    fmt.Sscanf("d", "%x", &x)
    fmt.Println(x)

    
    
    var z big.Int
    z.SetString("111", 3)
    fmt.Println(&z)

    
    z.SetString("0b1101", 0) 
    fmt.Println(&z)

    z.SetString("015", 0) 
    fmt.Println(&z)

    z.SetString("13", 0) 
    fmt.Println(&z)

    z.SetString("0xd", 0) 
    fmt.Println(&z)

    
    
    fmt.Sscanf("15", "%o", &z)
    fmt.Println(&z)
}
Task: Non-decimal radices_Input



C#: using System;

class Program
{
    static void Main()
    {
        var value = "100";
        var fromBases = new[] { 2, 8, 10, 16 };
        var toBase = 10;
        foreach (var fromBase in fromBases)
        {
            Console.WriteLine("{0} in base {1} is {2} in base {3}",
                value, fromBase, Convert.ToInt32(value, fromBase), toBase);
        }
    }
}



Java: Scanner sc = new Scanner(System.in); 
sc.useRadix(base); 
sc.nextInt();
Task: Non-decimal radices_Input



C#: using System;

class Program
{
    static void Main()
    {
        var value = "100";
        var fromBases = new[] { 2, 8, 10, 16 };
        var toBase = 10;
        foreach (var fromBase in fromBases)
        {
            Console.WriteLine("{0} in base {1} is {2} in base {3}",
                value, fromBase, Convert.ToInt32(value, fromBase), toBase);
        }
    }
}





Python: >>> text = '100'
>>> for base in range(2,21):
    print ("String '%s' in base %i is  %i in base 10" 
           % (text, base, int(text, base)))

  
String '100' in base 2 is  4 in base 10
String '100' in base 3 is  9 in base 10
String '100' in base 4 is  16 in base 10
String '100' in base 5 is  25 in base 10
String '100' in base 6 is  36 in base 10
String '100' in base 7 is  49 in base 10
String '100' in base 8 is  64 in base 10
String '100' in base 9 is  81 in base 10
String '100' in base 10 is  100 in base 10
String '100' in base 11 is  121 in base 10
String '100' in base 12 is  144 in base 10
String '100' in base 13 is  169 in base 10
String '100' in base 14 is  196 in base 10
String '100' in base 15 is  225 in base 10
String '100' in base 16 is  256 in base 10
String '100' in base 17 is  289 in base 10
String '100' in base 18 is  324 in base 10
String '100' in base 19 is  361 in base 10
String '100' in base 20 is  400 in base 10
Task: Non-decimal radices_Input




Go: package main

import (
    "fmt"
    "math/big"
    "strconv"
)

func main() {
    
    
    x, _ := strconv.Atoi("13")
    fmt.Println(x)

    
    
    
    
    x64, _ := strconv.ParseInt("3c2", 19, 64)
    fmt.Println(x64)

    
    
    
    
    
    
    fmt.Sscanf("1101", "%b", &x)
    fmt.Println(x)

    fmt.Sscanf("15", "%o", &x)
    fmt.Println(x)

    fmt.Sscanf("13", "%d", &x)
    fmt.Println(x)

    fmt.Sscanf("d", "%x", &x)
    fmt.Println(x)

    
    
    var z big.Int
    z.SetString("111", 3)
    fmt.Println(&z)

    
    z.SetString("0b1101", 0) 
    fmt.Println(&z)

    z.SetString("015", 0) 
    fmt.Println(&z)

    z.SetString("13", 0) 
    fmt.Println(&z)

    z.SetString("0xd", 0) 
    fmt.Println(&z)

    
    
    fmt.Sscanf("15", "%o", &z)
    fmt.Println(&z)
}




Python: >>> text = '100'
>>> for base in range(2,21):
    print ("String '%s' in base %i is  %i in base 10" 
           % (text, base, int(text, base)))

  
String '100' in base 2 is  4 in base 10
String '100' in base 3 is  9 in base 10
String '100' in base 4 is  16 in base 10
String '100' in base 5 is  25 in base 10
String '100' in base 6 is  36 in base 10
String '100' in base 7 is  49 in base 10
String '100' in base 8 is  64 in base 10
String '100' in base 9 is  81 in base 10
String '100' in base 10 is  100 in base 10
String '100' in base 11 is  121 in base 10
String '100' in base 12 is  144 in base 10
String '100' in base 13 is  169 in base 10
String '100' in base 14 is  196 in base 10
String '100' in base 15 is  225 in base 10
String '100' in base 16 is  256 in base 10
String '100' in base 17 is  289 in base 10
String '100' in base 18 is  324 in base 10
String '100' in base 19 is  361 in base 10
String '100' in base 20 is  400 in base 10
Task: Non-decimal radices_Input


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

int main()
{
  int num;

  std::istringstream("0123459") >> num;
  std::cout << num << std::endl; 

  std::istringstream("0123459") >> std::dec >> num;
  std::cout << num << std::endl; 

  std::istringstream("abcf123") >> std::hex >> num;
  std::cout << num << std::endl; 

  std::istringstream("7651") >> std::oct >> num;
  std::cout << num << std::endl; 

  

  return 0;
}




Java: Scanner sc = new Scanner(System.in); 
sc.useRadix(base); 
sc.nextInt();
Task: Non-decimal radices_Input


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

int main()
{
  int num;

  std::istringstream("0123459") >> num;
  std::cout << num << std::endl; 

  std::istringstream("0123459") >> std::dec >> num;
  std::cout << num << std::endl; 

  std::istringstream("abcf123") >> std::hex >> num;
  std::cout << num << std::endl; 

  std::istringstream("7651") >> std::oct >> num;
  std::cout << num << std::endl; 

  

  return 0;
}






Python: >>> text = '100'
>>> for base in range(2,21):
    print ("String '%s' in base %i is  %i in base 10" 
           % (text, base, int(text, base)))

  
String '100' in base 2 is  4 in base 10
String '100' in base 3 is  9 in base 10
String '100' in base 4 is  16 in base 10
String '100' in base 5 is  25 in base 10
String '100' in base 6 is  36 in base 10
String '100' in base 7 is  49 in base 10
String '100' in base 8 is  64 in base 10
String '100' in base 9 is  81 in base 10
String '100' in base 10 is  100 in base 10
String '100' in base 11 is  121 in base 10
String '100' in base 12 is  144 in base 10
String '100' in base 13 is  169 in base 10
String '100' in base 14 is  196 in base 10
String '100' in base 15 is  225 in base 10
String '100' in base 16 is  256 in base 10
String '100' in base 17 is  289 in base 10
String '100' in base 18 is  324 in base 10
String '100' in base 19 is  361 in base 10
String '100' in base 20 is  400 in base 10
Task: Non-decimal radices_Input





Java: Scanner sc = new Scanner(System.in); 
sc.useRadix(base); 
sc.nextInt(); 



Python: >>> text = '100'
>>> for base in range(2,21):
    print ("String '%s' in base %i is  %i in base 10" 
           % (text, base, int(text, base)))

  
String '100' in base 2 is  4 in base 10
String '100' in base 3 is  9 in base 10
String '100' in base 4 is  16 in base 10
String '100' in base 5 is  25 in base 10
String '100' in base 6 is  36 in base 10
String '100' in base 7 is  49 in base 10
String '100' in base 8 is  64 in base 10
String '100' in base 9 is  81 in base 10
String '100' in base 10 is  100 in base 10
String '100' in base 11 is  121 in base 10
String '100' in base 12 is  144 in base 10
String '100' in base 13 is  169 in base 10
String '100' in base 14 is  196 in base 10
String '100' in base 15 is  225 in base 10
String '100' in base 16 is  256 in base 10
String '100' in base 17 is  289 in base 10
String '100' in base 18 is  324 in base 10
String '100' in base 19 is  361 in base 10
String '100' in base 20 is  400 in base 10
Task: Non-decimal radices_Input

C: #include <stdio.h>

int main()
{
  int num;

  sscanf("0123459", "%d", &num);
  printf("%d\n", num); 

  sscanf("abcf123", "%x", &num);
  printf("%d\n", num); 

  sscanf("7651", "%o", &num);
  printf("%d\n", num); 

  

  return 0;
}





Java: Scanner sc = new Scanner(System.in); 
sc.useRadix(base); 
sc.nextInt();
Task: Non-decimal radices_Input

C: #include <stdio.h>

int main()
{
  int num;

  sscanf("0123459", "%d", &num);
  printf("%d\n", num); 

  sscanf("abcf123", "%x", &num);
  printf("%d\n", num); 

  sscanf("7651", "%o", &num);
  printf("%d\n", num); 

  

  return 0;
}







Python: >>> text = '100'
>>> for base in range(2,21):
    print ("String '%s' in base %i is  %i in base 10" 
           % (text, base, int(text, base)))

  
String '100' in base 2 is  4 in base 10
String '100' in base 3 is  9 in base 10
String '100' in base 4 is  16 in base 10
String '100' in base 5 is  25 in base 10
String '100' in base 6 is  36 in base 10
String '100' in base 7 is  49 in base 10
String '100' in base 8 is  64 in base 10
String '100' in base 9 is  81 in base 10
String '100' in base 10 is  100 in base 10
String '100' in base 11 is  121 in base 10
String '100' in base 12 is  144 in base 10
String '100' in base 13 is  169 in base 10
String '100' in base 14 is  196 in base 10
String '100' in base 15 is  225 in base 10
String '100' in base 16 is  256 in base 10
String '100' in base 17 is  289 in base 10
String '100' in base 18 is  324 in base 10
String '100' in base 19 is  361 in base 10
String '100' in base 20 is  400 in base 10
Task: Non-decimal radices_Input




Go: package main

import (
    "fmt"
    "math/big"
    "strconv"
)

func main() {
    
    
    x, _ := strconv.Atoi("13")
    fmt.Println(x)

    
    
    
    
    x64, _ := strconv.ParseInt("3c2", 19, 64)
    fmt.Println(x64)

    
    
    
    
    
    
    fmt.Sscanf("1101", "%b", &x)
    fmt.Println(x)

    fmt.Sscanf("15", "%o", &x)
    fmt.Println(x)

    fmt.Sscanf("13", "%d", &x)
    fmt.Println(x)

    fmt.Sscanf("d", "%x", &x)
    fmt.Println(x)

    
    
    var z big.Int
    z.SetString("111", 3)
    fmt.Println(&z)

    
    z.SetString("0b1101", 0) 
    fmt.Println(&z)

    z.SetString("015", 0) 
    fmt.Println(&z)

    z.SetString("13", 0) 
    fmt.Println(&z)

    z.SetString("0xd", 0) 
    fmt.Println(&z)

    
    
    fmt.Sscanf("15", "%o", &z)
    fmt.Println(&z)
}


Java: Scanner sc = new Scanner(System.in); 
sc.useRadix(base); 
sc.nextInt();
Task: Non-decimal radices_Input

C: #include <stdio.h>

int main()
{
  int num;

  sscanf("0123459", "%d", &num);
  printf("%d\n", num); 

  sscanf("abcf123", "%x", &num);
  printf("%d\n", num); 

  sscanf("7651", "%o", &num);
  printf("%d\n", num); 

  

  return 0;
}






PHP: <?php
echo +"0123459", "\n"; // prints 123459
echo intval("0123459"), "\n"; // prints 123459
echo hexdec("abcf123"), "\n"; // prints 180154659
echo octdec("7651"), "\n";  // prints 4009
echo bindec("101011001"), "\n"; // prints 345
?>
Task: Non-decimal radices_Input



C#: using System;

class Program
{
    static void Main()
    {
        var value = "100";
        var fromBases = new[] { 2, 8, 10, 16 };
        var toBase = 10;
        foreach (var fromBase in fromBases)
        {
            Console.WriteLine("{0} in base {1} is {2} in base {3}",
                value, fromBase, Convert.ToInt32(value, fromBase), toBase);
        }
    }
}




PHP: <?php
echo +"0123459", "\n"; // prints 123459
echo intval("0123459"), "\n"; // prints 123459
echo hexdec("abcf123"), "\n"; // prints 180154659
echo octdec("7651"), "\n";  // prints 4009
echo bindec("101011001"), "\n"; // prints 345
?>
Task: Non-decimal radices_Input


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

int main()
{
  int num;

  std::istringstream("0123459") >> num;
  std::cout << num << std::endl; 

  std::istringstream("0123459") >> std::dec >> num;
  std::cout << num << std::endl; 

  std::istringstream("abcf123") >> std::hex >> num;
  std::cout << num << std::endl; 

  std::istringstream("7651") >> std::oct >> num;
  std::cout << num << std::endl; 

  

  return 0;
}





PHP: <?php
echo +"0123459", "\n"; // prints 123459
echo intval("0123459"), "\n"; // prints 123459
echo hexdec("abcf123"), "\n"; // prints 180154659
echo octdec("7651"), "\n";  // prints 4009
echo bindec("101011001"), "\n"; // prints 345
?>
Task: Non-decimal radices_Input




Go: package main

import (
    "fmt"
    "math/big"
    "strconv"
)

func main() {
    
    
    x, _ := strconv.Atoi("13")
    fmt.Println(x)

    
    
    
    
    x64, _ := strconv.ParseInt("3c2", 19, 64)
    fmt.Println(x64)

    
    
    
    
    
    
    fmt.Sscanf("1101", "%b", &x)
    fmt.Println(x)

    fmt.Sscanf("15", "%o", &x)
    fmt.Println(x)

    fmt.Sscanf("13", "%d", &x)
    fmt.Println(x)

    fmt.Sscanf("d", "%x", &x)
    fmt.Println(x)

    
    
    var z big.Int
    z.SetString("111", 3)
    fmt.Println(&z)

    
    z.SetString("0b1101", 0) 
    fmt.Println(&z)

    z.SetString("015", 0) 
    fmt.Println(&z)

    z.SetString("13", 0) 
    fmt.Println(&z)

    z.SetString("0xd", 0) 
    fmt.Println(&z)

    
    
    fmt.Sscanf("15", "%o", &z)
    fmt.Println(&z)
}



PHP: <?php
echo +"0123459", "\n"; // prints 123459
echo intval("0123459"), "\n"; // prints 123459
echo hexdec("abcf123"), "\n"; // prints 180154659
echo octdec("7651"), "\n";  // prints 4009
echo bindec("101011001"), "\n"; // prints 345
?>
Task: Non-decimal radices_Input





Java: Scanner sc = new Scanner(System.in); 
sc.useRadix(base); 
sc.nextInt(); 


PHP: <?php
echo +"0123459", "\n"; // prints 123459
echo intval("0123459"), "\n"; // prints 123459
echo hexdec("abcf123"), "\n"; // prints 180154659
echo octdec("7651"), "\n";  // prints 4009
echo bindec("101011001"), "\n"; // prints 345
?>
Task: Non-decimal radices_Input






PHP: <?php
echo +"0123459", "\n"; // prints 123459
echo intval("0123459"), "\n"; // prints 123459
echo hexdec("abcf123"), "\n"; // prints 180154659
echo octdec("7651"), "\n";  // prints 4009
echo bindec("101011001"), "\n"; // prints 345
?>


Python: >>> text = '100'
>>> for base in range(2,21):
    print ("String '%s' in base %i is  %i in base 10" 
           % (text, base, int(text, base)))

  
String '100' in base 2 is  4 in base 10
String '100' in base 3 is  9 in base 10
String '100' in base 4 is  16 in base 10
String '100' in base 5 is  25 in base 10
String '100' in base 6 is  36 in base 10
String '100' in base 7 is  49 in base 10
String '100' in base 8 is  64 in base 10
String '100' in base 9 is  81 in base 10
String '100' in base 10 is  100 in base 10
String '100' in base 11 is  121 in base 10
String '100' in base 12 is  144 in base 10
String '100' in base 13 is  169 in base 10
String '100' in base 14 is  196 in base 10
String '100' in base 15 is  225 in base 10
String '100' in base 16 is  256 in base 10
String '100' in base 17 is  289 in base 10
String '100' in base 18 is  324 in base 10
String '100' in base 19 is  361 in base 10
String '100' in base 20 is  400 in base 10
Task: Execute HQ9+

C: void runCode(const char *code)
{
    int c_len = strlen(code);
    int i, bottles;
    unsigned accumulator=0;
    for(i=0;i<c_len;i++)
    {
        switch(code[i])
        {
            case 'Q':
                printf("%s\n", code);
                break;

            case 'H':
                printf("Hello, world!\n");
                break;

            case '9':
                
                bottles = 99;
                do {
                    printf("%d bottles of beer on the wall\n", bottles);
                    printf("%d bottles of beer\n", bottles);
                    printf("Take one down, pass it around\n");
                    printf("%d bottles of beer on the wall\n\n", --bottles);
                } while( bottles > 0 );
                break;

            case '+':
                
                accumulator++;
                break;
        }
    }
};



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

class Program
{
    static void RunCode(string code)
    {
        int accumulator = 0;
        var opcodes = new Dictionary<char, Action>
        {
            {'H', () => Console.WriteLine("Hello, World!"))},
            {'Q', () => Console.WriteLine(code) },
            {'9', () => Console.WriteLine(Enumerable.Range(1,100).Reverse().Select(n => string.Format("{0} bottles of beer on the wall\n{0} bottles of beer\nTake one down, pass it around\n{1} bottles of beer on the wall\n", n, n-1)).Aggregate((a,b) => a + "\n" + b))},
            {'+', () => accumulator++ }
        }

        foreach(var c in code)
            opcodes[c]();
    }
}