Dailyprogammer Challenge #199 - Bank Numbers Pt 1
I have attempted another dailyprogammer challenge on reddit.
This time, the challenge is to take a number in and print a 'banner' representing that number, like this:
Input: 47262
Output:
_ _ _ _
|_| | _||_ _|
| ||_ |_||_
Here is my solution:
using System;
public class BigDigits
{
static string[,] bannerTemplates = new string[,]{
{ " _ ", "| |", "|_|" },
{ " ", " |", " |" },
{ " _ ", " _|", "|_ " },
{ " _ ", " _|", " _|" },
{ " ", "|_|", " |" },
{ " _ ", "|_ ", " _|" },
{ " _ ", "|_ ", "|_|" },
{ " _ ", " |", " |" },
{ " _ ", "|_|", "|_|" },
{ " _ ", "|_|", " _|" }
};
static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("This program converts a number to a banner.");
Console.WriteLine("\nUse it like this: ");
Console.WriteLine(" bigintbanners.exe <number>");
Console.WriteLine("\n<number>: The number you want to convert.");
return;
}
char[] intChars = args[0].ToCharArray();
string[] resultLines = new string[3];
int currentDigit = 0;
int i = 0;
for(i = 0; i < intChars.Length; i++)
{
currentDigit = int.Parse(intChars[i].ToString());
for (int j = 0; j < 3; j++)
{
resultLines[j] += bannerTemplates[currentDigit,j];
}
}
for(i = 0; i < resultLines.Length; i++)
{
Console.WriteLine(resultLines[i]);
}
}
}
I find the dailyprogrammer challenges to be a great way to practice a language that you are learning.
32 bit binary, SHA1: 0fc2483dacf151b162e22b3f9b4c5c64e6fe5bdf
Ask below if you need a different binary (e.g. 64 bit, ARM, etc)
Reddit
The first one is a flexible multiple choice selection window. You can pass in an array of string sthat you want the user to choose from, and the method will deal with the rest, returning the index in the array of the item that the user chose.