From 3454dcabf0380f6c8c3580ad3ff4838475ed4fea Mon Sep 17 00:00:00 2001 From: jrg94 <11050412+jrg94@users.noreply.github.com> Date: Sun, 5 Oct 2025 23:49:14 -0400 Subject: [PATCH] Implemented RemoveAllWhitespace --- archive/k/kotlin/RemoveAllWhitespace.kt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 archive/k/kotlin/RemoveAllWhitespace.kt diff --git a/archive/k/kotlin/RemoveAllWhitespace.kt b/archive/k/kotlin/RemoveAllWhitespace.kt new file mode 100644 index 000000000..f6f4cd056 --- /dev/null +++ b/archive/k/kotlin/RemoveAllWhitespace.kt @@ -0,0 +1,22 @@ +import kotlin.system.exitProcess + +fun main(args: Array) { + val phrase: String = errorChecking(args) + println(removeWhitespace(phrase)) +} + +fun usageError() { + println("Usage: please provide a string") +} + +fun errorChecking(args: Array): String { + if (args.size == 0 || args[0] == "") { + usageError() + exitProcess(1) + } + return args[0] +} + +fun removeWhitespace(phrase: String): String { + return phrase.filter { !it.isWhitespace() } +}