Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public class Dinglemouse
- {
- static string origString = "";
- public static HashSet<string> TrueBananas(string s)
- {
- var result = new HashSet<string>();
- string pure = s.Replace("-", String.Empty);
- if (pure.Length == 6)
- {
- if (pure == "banana")
- result.Add(s);
- }
- else if (pure.Length < 6)
- {
- for (int i = 0; i < s.Length && s[i] == '-'; i++)
- {
- result.UnionWith(
- TrueBananas(
- ReplaceByIndex(s, i, origString[i])
- )
- );
- }
- }
- return result;
- }
- public static HashSet<string> Bananas(string s)
- {
- origString = s;
- string mask = "";
- foreach (char i in s)
- mask += '-';
- var result = new HashSet<string>();
- result.UnionWith(TrueBananas(mask));
- return result;
- }
- static string ReplaceByIndex(string oldStr, int index, char newChar)
- {
- string temp = "";
- for (int i = 0; i < oldStr.Length; i++)
- temp += (index == i ? newChar : oldStr[i]);
- return temp;
- }
- }
Advertisement
RAW Paste Data
Copied
Advertisement