informaticage

Uracile e demoni

Jan 22nd, 2021 (edited)
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. s = "ATACTTTTCUUAAUU"
  2. _s = [_ for _ in s]
  3.  
  4. for i in range (0, len(_s) - 1):
  5.     if(_s[i] != _s[i + 1]):
  6.         j = i + 1
  7.         while(_s[j] == _s[i + 1] and j < len(_s) - 1):
  8.            j += 1
  9.        
  10.         if(_s[i] == _s[j]):
  11.             print(_s[i:(j+1)])
  12.        
  13.         i = j
  14.  
  15.  
  16.  
  17. const s = "ATACTTTC____";
  18.  
  19. const _a = s.split('');
  20.  
  21. for(let i = 0; i < _a.length - 1; i++) {
  22.     console.log('primo: ', _a[i]);
  23.     if(_a[i] !== _a[i + 1]) {
  24.         let j = i + 1;
  25.         while(_a[j] === _a[i + 1]) {
  26.             // Sto continuanto a trovare roba in mezzo uguale
  27.             j++;
  28.             console.log('check con ', _a[j]);
  29.         }
  30.        
  31.         /// ho trovasto qualcosa di diverso che mi ha fatto uscire
  32.         // controllo se quella cosa diversa è uguale all'inizio stringa
  33.        if(_a[i] === _a[j])
  34.            console.log('Ho trovato ', s.substr(i, j - i + 1));
  35.        
  36.        i = j;
  37.    }
  38. }
  39.  
Add Comment
Please, Sign In to add comment