-
-
Save mtgto/5133092 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
import java.util.Random | |
object HelloWorld extends App { | |
println(randomString(748171626L) +" "+ randomString(31718954746L)) | |
println(randomString2(748171626L) +" "+ randomString2(31718954746L)) | |
def randomString(i :Long) :String = { | |
val rand = new Random(i) | |
val sb = new StringBuilder() | |
rs(rand.nextInt(27)) | |
def rs(k :Int) { | |
if (k == 0) return | |
else { | |
sb.append(('`' + k).toChar) | |
rs(rand.nextInt(27)) | |
} | |
} | |
sb.toString | |
} | |
def randomString2(i :Long) :String = { | |
val rand = new Random(i) | |
def mkList(rand :Random) :List[Int] = { | |
val k = rand.nextInt(27) | |
if (k == 0) Nil | |
else k :: mkList(rand) | |
} | |
("" /: mkList(rand)){ (x, y) => x + (('`' + y).toChar.toString) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment