private String BreakIntoNumbers(String number) { long numAsInt = long.Parse(number); int randomNumber = RandomUtils.GenerateLittleInt(); Random random = new Random(); switch (random.Next(0, 4)) { case 0: { if (random.Next(0, 4) == 0) { return("( " + BreakIntoNumbers((numAsInt - randomNumber).ToString()) + " + " + BreakIntoNumbers((randomNumber).ToString()) + " )"); } else { return("( " + (numAsInt - randomNumber) + " + " + (randomNumber) + " )"); } } case 1: { if (random.Next(0, 4) == 0) { return("( " + BreakIntoNumbers((numAsInt + randomNumber).ToString()) + " - " + BreakIntoNumbers((randomNumber).ToString()) + " )"); } else { return("( " + (numAsInt + randomNumber) + " - " + (randomNumber) + " )"); } } case 2: { List <long> dividers = new List <long>(); long divider = Math.Abs(numAsInt) - 1; while (divider > 0) { if (numAsInt % divider == 0) { dividers.Add(divider); } divider--; } divider = (dividers.Count == 0) ? Math.Abs(numAsInt) : dividers[random.Next(0, dividers.Count)]; if (divider == 0) { return(BreakIntoNumbers(number)); } if (random.Next(0, 4) == 0) { return("( " + BreakIntoNumbers((numAsInt / divider).ToString()) + " * " + BreakIntoNumbers((divider).ToString()) + " )"); } else { return("( " + (numAsInt / divider) + " * " + (divider) + " )"); } } case 3: { if (random.Next(0, 4) == 0) { return("( " + BreakIntoNumbers((numAsInt * randomNumber).ToString()) + " / " + BreakIntoNumbers((randomNumber).ToString()) + " )"); } else { return("( " + (numAsInt * randomNumber) + " / " + (randomNumber) + " )"); } } default: return(number); } }
public override SyntaxTrivia VisitTrivia(SyntaxTrivia trivia) { if (trivia.IsKind(SyntaxKind.SingleLineCommentTrivia)) { return(SyntaxFactory.SyntaxTrivia(SyntaxKind.SingleLineCommentTrivia, cipherUtils.Encipher(trivia.ToFullString().ToString(), RandomUtils.generateIntInAlphabetRange()))); } return(base.VisitTrivia(trivia)); }