Skip to content

Instantly share code, notes, and snippets.

@vdonchev
Created May 17, 2016 06:37
Show Gist options
  • Select an option

  • Save vdonchev/26d6775e46ea418f87ea19bc63db71c6 to your computer and use it in GitHub Desktop.

Select an option

Save vdonchev/26d6775e46ea418f87ea19bc63db71c6 to your computer and use it in GitHub Desktop.
namespace Medenka
{
using System;
using System.Text;
public static class Medenka
{
private static StringBuilder result = new StringBuilder();
static void Main(string[] args)
{
var arr = Console.ReadLine().Split();
Cut(arr, string.Empty);
Console.WriteLine(result.ToString().Trim());
}
private static void Cut(string[] arr, string res, int index = 0, bool found = false)
{
while (index < arr.Length)
{
if (arr[index] == "1")
{
if (found)
{
res += "|1";
}
else
{
res += "1";
found = true;
}
}
else
{
if (found)
{
Cut(arr, res + "|0", index + 1);
}
res += "0";
}
index++;
}
result.AppendLine(res);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment