SHARE
TWEET

Untitled

a guest Sep 19th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun main(args: Array<String>) {
  2. //    val givenInput = ""
  3.     val givenInput = "abc"
  4.  
  5.     fun invertName(name: String): String {
  6.         require(name.isNotEmpty()) { "The string must not be empty" }
  7.         val result = name.split("").reversed().joinToString("").substring(1)
  8.         check(result.length == name.length) { "Input and output sized should not be different" }
  9.         assert(name.first() == result.last()) { "The first letter \"${name.first()}\" of the input should be the last one of the output" }
  10.         return result
  11.     }
  12.  
  13.     print(invertName(givenInput))
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top