daily pastebin goal
86%
SHARE
TWEET

Untitled

a guest Jan 13th, 2012 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun main(args : Array<String>) {
  2.  
  3.   val input : String = "ddddfhfj hj jhhjyiui i iu iui4 iu 5ui5u5u5uhhhhhhu5uu55uuuuuuufjj555"
  4.  
  5.   var maxStart : Int = 0
  6.   var maxEnd : Int = 0
  7.   var start : Int = 0
  8.   var end : Int = 0
  9.  
  10.   for (var i in 0..input.length) {
  11.     if (i == input.length || !Character.isLetter(input.get(i))) {
  12.       start = i + 1
  13.       end = i + 1
  14.     } else {
  15.       end = i + 1
  16.     }    
  17.     if (end - start > maxEnd - maxStart) {
  18.       maxStart = start
  19.       maxEnd = end
  20.     }
  21.   }
  22.  
  23.   System.out?.println(input.substring(maxStart, maxEnd))
  24. }
RAW Paste Data
Top