Note: this is from http://softwaremaniacs.org/playground/showdown-highlight/
To see the markdown equivalent from this text, see the RAW of this file.
This is an overview of Markdown's syntax. For more information, visit the [Markdown web site].
Note: this is from http://softwaremaniacs.org/playground/showdown-highlight/
To see the markdown equivalent from this text, see the RAW of this file.
This is an overview of Markdown's syntax. For more information, visit the [Markdown web site].
package com.example.app.shape | |
import kotlin.math.cos | |
import kotlin.math.min | |
import kotlin.math.sin | |
import kotlin.math.sqrt | |
import kotlin.math.tan | |
internal class SmoothCorner( | |
private val cornerRadius: Float, |
void withIf() { | |
Map<int, void> items = { | |
1: (), | |
2: (), | |
3: (), | |
4: (), | |
5: (), | |
}; | |
items.forEach( |
val Int.isPrime: Boolean | |
get() { | |
if (this <= 1) return false | |
for (i in 2..<this) { | |
if (this % i == 0) return false | |
} | |
return true | |
} |
import java.util.* | |
class TextEditor(initialValue: String = "") { | |
private val operationHistory = Stack<String>().apply { push(initialValue) } | |
val value: String | |
get() = operationHistory.peek() | |
fun append(text: String) { | |
operationHistory.push(operationHistory.peek() + text) |
import java.util.* | |
const val RESULT_YES = "YES" | |
const val RESULT_NO = "NO" | |
fun isBalanced(s: String): String { | |
val stack = Stack<Char>() | |
s.forEach { char -> | |
when (char) { | |
'[' -> stack.push(']') |
import java.util.* | |
const val QUEUE_ENQUEUE = 1 | |
const val QUEUE_DEQUEUE = 2 | |
const val QUEUE_PRINT_HEAD = 3 | |
fun queueUsingTwoStacks( | |
numberOfQueues: Int, | |
scanner: Scanner = Scanner(System.`in`), | |
) { |
fun IntArray.alternateSort(): IntArray { | |
require(this.isNotEmpty()) { "There must be at least one element" } | |
this.sort() | |
val result = mutableListOf<Int>() | |
var j = this.lastIndex | |
var i = 0 | |
while (i < j) { |