Skip to content

Instantly share code, notes, and snippets.

@sguzunov
Created February 26, 2018 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sguzunov/08f19e6ec29e06f587a9170341153b18 to your computer and use it in GitHub Desktop.
Save sguzunov/08f19e6ec29e06f587a9170341153b18 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BarcodeGenerator
{
class Program
{
static void Main(string[] args)
{
string firstNumberAsString = Console.ReadLine(); // "3333"
string secondNumberAsString = Console.ReadLine(); // "3339"
int firstStart = (int)Char.GetNumericValue(firstNumberAsString[0]); // -> char '3' -> 3
int firstEnd = (int)Char.GetNumericValue(secondNumberAsString[0]);
int secondStart = (int)Char.GetNumericValue(firstNumberAsString[1]);
int secondEnd = (int)Char.GetNumericValue(secondNumberAsString[1]);
int thirdStart = (int)Char.GetNumericValue(firstNumberAsString[2]);
int thirdEnd = (int)Char.GetNumericValue(secondNumberAsString[2]);
int fourthStart = (int)Char.GetNumericValue(firstNumberAsString[3]);
int fourthEnd = (int)Char.GetNumericValue(secondNumberAsString[3]);
// 2323
firstStart = firstStart % 2 == 0 ? firstStart + 1 : firstStart;
secondStart = secondStart % 2 == 0 ? secondStart + 1 : secondStart;
thirdStart = thirdStart % 2 == 0 ? thirdStart + 1 : thirdStart;
fourthStart = fourthStart % 2 == 0 ? fourthStart + 1 : fourthStart;
for (int firstDigit = firstStart; firstDigit <= firstEnd; firstDigit += 2)
{
for (int secondDigit = secondStart; secondDigit <= secondEnd; secondDigit += 2)
{
for (int thirdDigit = thirdStart; thirdDigit <= thirdEnd; thirdDigit += 2)
{
for (int fourthDigit = fourthStart; fourthDigit <= fourthEnd; fourthDigit += 2)
{
Console.Write("{0}{1}{2}{3} ", firstDigit, secondDigit, thirdDigit, fourthDigit);
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment