Skip to content

Instantly share code, notes, and snippets.

@daniele-quero
Created September 4, 2023 14:18
Show Gist options
  • Save daniele-quero/b0941b7969b8375a5b31e17503b1ff2e to your computer and use it in GitHub Desktop.
Save daniele-quero/b0941b7969b8375a5b31e17503b1ff2e to your computer and use it in GitHub Desktop.
private string TranslateByProficiency(string s, float p)
{
if (p == 1) return s;
if (p == 0) return CoverText.CoverTextWith(s, "x");
var words = s.Split(" ");
for (int i = 0; i < words.Length; i++)
{
if (Random.value > p)
{
var array = words[i].ToCharArray();
Durstenfeld<char>.shuffle(array);
words[i] = new string(array);
}
}
return string.Join(" ", words);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment