fun solve(line: String): Boolean { if(line.isEmpty()) return false var s = line.toLowerCase(); for (i in 0 until 3){ if(s.isEmpty()) return false if(!s.last().isLetterOrDigit() && s.last() != ' ') s = s.dropLast(1) } if(s.isEmpty()) return false if (line.startsWith("digi ")){ return s.endsWith("nyo") }else if (line.startsWith("petit ")){ return s.endsWith("nyu"); }else if(line.startsWith("rabi ")){ return s.length >= 5 && s.subSequence(5, s.length).any { it.isLetterOrDigit()} }else if(line.startsWith("gema ")){ return s.endsWith("gema") }else if(line.startsWith("piyo ")) return s.endsWith("pyo") else return false } fun main(args: Array) { var s : String? do { s = readLine() if(s == null) break println( if (solve(s)) "CORRECT (maybe)" else "WRONG!") } while (true) }