fork download
  1. def comparing_rotated_words(word):
  2. w = sorted(list(word))
  3. pos_sol = []
  4. for i in range(len(word.lower())):
  5. if w[0] == word[i]:
  6. pos_sol.append([i, word[i:]+word[:i]])
  7.  
  8. return str(sorted(pos_sol, key=lambda x: x[1])[0][0]) + ' ' + sorted(pos_sol, key=lambda x: x[1])[0][1]
  9.  
  10. print(comparing_rotated_words('onion'))
  11. print(comparing_rotated_words('bbaaccaadd'))
  12. print(comparing_rotated_words('alfalfa'))
  13. print(comparing_rotated_words('weugweougewoiheew'))
  14. print(comparing_rotated_words('pneumonoultramicroscopicsilicovolcanoconiosis'))
Success #stdin #stdout 0s 23304KB
stdin
Standard input is empty
stdout
2 ionon
2 aaccaaddbb
6 aalfalf
14 eewweugweougewoih
12 amicroscopicsilicovolcanoconiosispneumonoultr