Created
September 5, 2010 13:29
-
-
Save eferm/566019 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
| public static String explode(String ascii) { | |
| // output string dimensioned for typical output size | |
| StringBuilder output = new StringBuilder(RATIO*ascii.length()); | |
| for (int i = 0; i < ascii.length(); i++) { | |
| String num = ascii.substring(i,i+1); // number to be hidden | |
| // next occurence of num in pi at what index? | |
| int index = pi.indexOf(num, INTERVAL+output.length()); | |
| // add some noise that doesn't match the corresponding digits in pi | |
| for (int j = output.length(); j < index; j++) { | |
| int k; | |
| do { | |
| k = (int) (10 * Math.random()); // random number, 0-9 | |
| } while (k == Integer.parseInt(pi.substring(j,j+1))); | |
| output.append((int) k); | |
| } | |
| output.append(num); | |
| } | |
| return output.toString(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment