SHARE
TWEET

Gamification in a team tool#2

a guest May 21st, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun findMarkerIgnoringSpace(text: String, marker: String): TextRange?{
  2.  
  3.     var revMarker = marker.length - 1
  4.  
  5.     loop@for(i in 0..text.length) {
  6.         while(text[i] == ' ') {
  7.  
  8.             continue@loop
  9.         }
  10.  
  11.         if(text[i] == marker[revMarker]) {
  12.             var copyI = i
  13.  
  14.             while(revMarker >= 0) {
  15.                 while(text[copyI] == ' ') {
  16.                     copyI--
  17.                 }
  18.                 while(marker[revMarker] == ' ') {
  19.                     revMarker--
  20.                 }
  21.  
  22.                 if(text[copyI] == marker[revMarker]) {
  23.                     revMarker--
  24.                     copyI--
  25.                 }else {
  26.                     break
  27.                 }
  28.             }
  29.  
  30.             if(revMarker<0) {
  31.                 return TextRange(copyI+1, i)
  32.             }else {
  33.                 revMarker = marker.length - 1
  34.             }
  35.         }
  36.     }
  37.  
  38.     return null
  39. }
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