Created
September 4, 2023 14:18
-
-
Save daniele-quero/b0941b7969b8375a5b31e17503b1ff2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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