Skip to content

Instantly share code, notes, and snippets.

@MFazio23
Created June 16, 2020 15:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MFazio23/8430b18c1e4aa95cddd244d703f2fe2b to your computer and use it in GitHub Desktop.
Save MFazio23/8430b18c1e4aa95cddd244d703f2fe2b to your computer and use it in GitHub Desktop.
Kotlin "hello world!" Function
// This is my answer to https://www.codewars.com/kata/523b4ff7adca849afe000035/train/kotlin
// Please don't try this at home, kids.
import kotlin.math.*
private val bird = 33
fun greet() =
"""
Oh yay, another starter function. Why is it always 'hello, world!'?
Apparently it started with 'A Tutorial Introduction to the Language B',
a book by Brian Kernighan. Usage continued with 'The C Programming Language',
also written by Kernighan along with Dennis Ritchie. If you're not familiar,
it's a super important book for a myriad of reasons and most modern languages
have concepts/syntax/conventions influenced by C.
With that said, this is an awful way to write a 'hello, world!' program.
If you learn anything here, make sure it's this bit of history, not the
gratuitous code below.
"""
.trimIndent()
.filter { it.isLetter() }
.filterNot { it.isUpperCase() }
.slice(((PI * (100.2 + floor(12.345678))).toInt())..((984.0) / E).toInt())
.map { max(it.toLong() * PI.pow(84 % 7), it.toDouble().ulp).toLong() }
.filterNot { it < floor(133.33 % 12.31).pow(2) }
.joinToString("") { it.toChar().toString().toLowerCase() }
.chunked(4372 % 397)
.joinToString('\u0020'.toString())
.plus((bird).toChar().toString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment