This file contains 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
fun main() = println("Greetings Earth!") |
This file contains 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
val words = arrayOf( | |
"out", "of", "mind", | |
"back", "in", "five") | |
println(words[2]) // prints "mind" |
This file contains 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
$ kotlin example.EchoKt Testing 1 2 3... | |
Testing 1 2 3... |
This file contains 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
// File: Echo.kt | |
package example | |
fun main(args: Array<String>) { | |
println(args.joinToString(" ")) | |
} |
This file contains 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
// Java | |
do { | |
// ... shuffling stuff... | |
// Ensure shuffling took place! | |
} while(IntStream.range(start, end) | |
.allMatch(i -> | |
result[i] == text.charAt(i) | |
})); |
This file contains 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
// Shuffle inner letter array | |
for (i in range) { | |
// Choose a random index in region | |
val rndIdx: Int = range.random() | |
// Swap current/random chars | |
result[rndIdx] = result[i].also { | |
result[i] = result[rndIdx] | |
} | |
} |
This file contains 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
// Shuffle inner letter array | |
for (var i = start; i < end; i++) { | |
// Choose a random index in region | |
final var rndIdx = | |
start + random.nextInt(length); | |
// Swap current/random chars | |
final var save = result[rndIdx]; | |
result[rndIdx] = result[i]; | |
result[i] = save; | |
} |
This file contains 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
// Examine text looking for matches | |
WORD_REGEX.findAll(text) | |
.forEach { match -> | |
// Define range of inner letters | |
val range: IntRange = | |
match.range.first + 1 | |
until match.range.last | |
// ... shuffling stuff ... | |
} |
This file contains 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
// Examine text looking for matches | |
WORD_REGEX.matcher(text).results() | |
.forEach(match -> { | |
// Second letter | |
final var start = match.start() + 1; | |
// Penultimate letter | |
final var end = match.end() - 1; | |
final var length = end - start; | |
// ... shuffling stuff ... | |
} |
This file contains 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
\p{IsLatin}(\p{IsLatin})\1*(?!\1)\p{IsLatin}\p{IsLatin}+ |