//Jamie Silva //Lakota East High School //SR-3 //Contest #2 //Language = C# using System; using System.IO; namespace ACSLContestTwo { class Program { static void Main(string[] args) { StreamReader input; bool finished = false; string fileName = "c:\\acsldata.txt"; do { try { input = new StreamReader(fileName); } catch (FileNotFoundException) { Console.WriteLine("\n\nFile not found!\n\nTry again."); Console.Write("Enter the complete data file name: "); fileName = Console.ReadLine(); continue; } while (!input.EndOfStream) { try { string inLine = input.ReadLine(); string[] data = inLine.Split(','); int inputNum = Convert.ToInt32(data[0]); int strLength = data[1].Length; string result = ""; int starCount = 0; for (int j = 0; j < strLength - 1; j++) { string[] chars = new string[inputNum]; bool hasZero = false; bool hasOne = false; for (int k = 0; k < inputNum; k++) { switch (data[k + 1].Substring(j + 1, 1)) { case "0": hasZero = true; break; case "1": hasOne = true; break; } } if (hasOne) { if (hasZero) { starCount++; result += "*"; } else { result += "1"; } } else { result += "0"; } } int starMax = 0; if (inputNum == 8) { starMax = 3; } else if (inputNum >= 4) { starMax = 2; } else if (inputNum >= 2) { starMax = 1; } else { starMax = 0; } if (starCount <= starMax) { Console.WriteLine(result + "\n"); } else { Console.WriteLine("NONE\n"); } } catch (Exception) { Console.WriteLine("Something went wrong. Moving to the next entry."); continue; } } finished = true; } while (!finished); } } }