Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static String BackwardsNumCheck(ulong Num, String currentEnum)
- {
- Num = Num > 9 ? 9 : Num; //if num is greater than 9, then we just default to greatest possible number
- List<char> test = new List<char>(); //turn it into a list for reversing
- //potential for doing incrementation loop here with a carry boolean
- //just fuckin do it backwards lul
- //enumerate through initial string and go from there
- bool carry = false; // this will tell the below loop whether it needs to add 1 to the next number or not, thus saving an entire loop over of the stringset
- foreach (char c in currentEnum.Reverse()) //reverse the string in so that we don't need to do recursive calling
- {
- uint bar = uint.Parse(c.ToString()); //convert the char to an integer we can work with
- if (carry)
- {
- bar++; //if carry bit is present, add 1
- carry = false;
- }
- test.Add(((bar > Num ? Convert.ToChar(bar + 1) : c) > Num ? (carry = true) : carry = false) ? '1' : Convert.ToChar(bar+1)); //if the char is greater than num, increment it, otherwise put the regular char in
- }
- //reverse the reversed string for checking if it contains the sequences
- test.Reverse();
- //compile list into a full string
- String foo = "";
- foreach (char c in test) //sequence the string
- {
- foo += c;
- }
- return foo; //return string that is proper way around
- }
Advertisement
Add Comment
Please, Sign In to add comment