59
1
using System;
2
using System.Diagnostics;
3
using System.Collections.Generic;
4
5
public class Program {
6
public static void Main() {
7
Random r = new Random();
8
for (int i = 0; i < 10000; i++) {
9
var rndBase = r.Next(2, 62);
10
var encoded = NumberToBase(i, rndBase);
11
var decoded = NumberFromBase(encoded, rndBase);
12
if (i != decoded) {
13
Console.WriteLine("i: {0} enc: {1} dec: {2}", i, encoded, decoded);
14
}
15
}
16
Console.WriteLine("Completed no errors");
17
}
18
19
// Define other methods and classes here
20
private const string BASE_DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
21
/// <summary>
22
/// Convert a base 10 number to a different base.
23
/// </summary>
24
/// <param name = "number">Number to convert</param>
Cached Result