Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<String> BinaryToUnary(List<string> value)
- {
- var temp = new List<string>();
- var temp2 = new List<string>();
- var temp3 = new List<string>();
- string hold = "";
- int count = 1;
- TxtToDisPlay = "Major Step 1: replace All 1 with 0l userInput " + string.Join("", value) + "nn";
- foreach (var x in value)
- {
- if (x.Equals("1"))
- {
- temp.Add("0l");
- TxtToDisPlay = TxtToDisPlay + "Step " + count + ": " + x + " = " + "0l" + "n";
- }
- else
- {
- temp.Add(x);
- TxtToDisPlay = TxtToDisPlay + "Step " + count + ": " + x + " = " + x + "n";
- }
- count++;
- }
- TxtToDisPlay = TxtToDisPlay + "nnMajor Step 2: Replace all l0 with 0ll userInput = " + string.Join("", temp) + " nn";
- foreach (var x in string.Join("", temp))
- {
- hold = hold + x;
- if (hold.Equals("l0"))
- {
- temp2.Add("0ll");
- TxtToDisPlay = TxtToDisPlay + "Step " + count + ": " + hold + " = " + "0ll" + "n";
- hold = "";
- }
- if (hold.Equals("0"))
- {
- temp2.Add(hold);
- TxtToDisPlay = TxtToDisPlay + "Step " + count + ": " + hold + " = " + hold + "n";
- hold = "";
- }
- count++;
- }
- if (hold.Equals("l"))
- {
- temp2.Add("l");
- }
- hold = "";
- foreach (var y in string.Join("", temp2))
- {
- if (temp2.Count == 1)
- {
- temp3.Add("l");
- break;
- }
- hold = hold + y;
- if (hold.Equals("l0"))
- {
- TxtToDisPlay = TxtToDisPlay + "Step " + count + ": " + hold + " = " + "0ll" + "n";
- temp3.Add("0ll");
- hold = "";
- }
- if (hold.Equals("0") || hold.Equals("ll"))
- {
- if (hold.Equals("ll"))
- {
- TxtToDisPlay = TxtToDisPlay + "Step " + count + ": " + hold + " = " + hold + "n";
- temp3.Add("l");
- hold = "l";
- }
- else
- {
- TxtToDisPlay = TxtToDisPlay + "Step " + count + ": " + hold + " = " + hold + "n";
- temp3.Add(hold);
- hold = "";
- }
- }
- }
- if (value.Count == 3 && hold.Equals("l"))
- {
- temp3.Add("l");
- temp3.Add("l");
- }
- else if (value.Count == 3 || hold.Equals("l"))
- {
- temp3.Add("l");
- }
- TxtToDisPlay = TxtToDisPlay + "nnMajor Step 3 : get rid of the 0 from userInput = " + string.Join("", temp3) + " nn";
- var answer = new List<string>();
- foreach (var x in temp3)
- {
- if (x.Contains("0ll"))
- {
- foreach (var y in x.Where(y => y.Equals('l')))
- {
- answer.Add("l");
- TxtToDisPlay = TxtToDisPlay + "Step " + count + ": " + "x = l so " + "Add l To new Array result = " + string.Join("", answer) + "n";
- }
- }
- else if (x.Contains("l"))
- {
- TxtToDisPlay = TxtToDisPlay + "Step " + count + ": " + "Add l To new Array result = " + string.Join("", answer) + "n";
- answer.Add(x);
- }
- count++;
- }
- return answer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement