Created
November 5, 2016 15:15
-
-
Save je6bmq/f010704a03176aaed8cfad126758e73d 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
tailrec fun PPAP( pcount:Int=0, isA:Boolean=false) | |
{ | |
val rnd=Random() | |
val c=if (rnd.nextBoolean()) "P" else "A" | |
print(c) | |
when(c) | |
{ | |
"P" -> when{ | |
isA && pcount>=2->println("") | |
else ->PPAP(pcount+1,false) | |
} | |
else ->PPAP(if (isA||pcount<2) 0 else pcount,true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment