fork(3) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace digital_led_number
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var numbers = new Dictionary<string, int>();
  12. List<string> replacedNumbersList = new List<string>();
  13. List<int> finalNumbers = new List<int>();
  14. List<string> result = new List<string>();
  15.  
  16. int iterator = 1;
  17. int startingPoint = 0;
  18. bool readLines = true;
  19.  
  20. numbers.Add("010101111", 0);
  21. numbers.Add("000001001", 1);
  22. numbers.Add("010011110", 2);
  23. numbers.Add("010011011", 3);
  24. numbers.Add("000111001", 4);
  25. numbers.Add("010110011", 5);
  26. numbers.Add("010110111", 6);
  27. numbers.Add("010001001", 7);
  28. numbers.Add("010111111", 8);
  29. numbers.Add("010111001", 9);
  30. while (readLines)
  31. {
  32. string line = Console.ReadLine();
  33.  
  34. if (String.IsNullOrEmpty(line))
  35. {
  36. readLines = false;
  37. }
  38. string replacedLine = GetReplacedString(line);
  39. int numbersInLine = replacedLine.Length / 3;
  40.  
  41. for (int j = 0; j < replacedLine.Length; j+=3)
  42. {
  43. string x = replacedLine.Substring(j, 3);
  44. replacedNumbersList.Add(x);
  45. }
  46.  
  47. if (iterator % 3 == 0)
  48. {
  49. for (int i = 0; i < numbersInLine; i++)
  50. {
  51. string currentNumber = "";
  52. for (int j = startingPoint + i; j < replacedNumbersList.Count; j+= numbersInLine)
  53. {
  54. currentNumber += replacedNumbersList[j];
  55. }
  56.  
  57. finalNumbers.Add(numbers[currentNumber]);
  58. }
  59.  
  60. startingPoint = replacedNumbersList.Count;
  61. string final = "";
  62. finalNumbers.ForEach(p => final += p.ToString());
  63. result.Add(final);
  64. }
  65.  
  66. if (readLines)
  67. {
  68. iterator++;
  69. }
  70. }
  71.  
  72. string someString = result[result.Count - 1];
  73. string parsedSomeString = someString;
  74. int iteratorMultiple = (iterator / 3) > 0 ? (iterator / 3) : 1;
  75. int counterValue = parsedSomeString.Length / iteratorMultiple;
  76.  
  77. for (int j = 0; j < parsedSomeString.Length; j+= counterValue)
  78. {
  79. string x = parsedSomeString.Substring(j, counterValue);
  80. Console.WriteLine(x);
  81. }
  82. }
  83.  
  84. static string GetReplacedString(string s)
  85. {
  86. return new StringBuilder(s)
  87. .Replace(" ", "0")
  88. .Replace("_", "1")
  89. .Replace("|", "1")
  90. .ToString();
  91. }
  92. }
  93. }
Success #stdin #stdout 0.02s 16348KB
stdin
 _  _  _  _  _  _ 
 _| _| _|| ||_||_ 
|_  _||_ |_|  | _|
    _     _     _ 
  ||_ |_||_   || |
  ||_|  ||_|  ||_|
 _  _  _  _     _ 
  ||_||_||_   ||_|
  |  |  | _|  ||_|
stdout
232095
164610
799518