fork download
  1. # using words instead of numbers
  2. numbers = ["hello", "this", "is", "is", "is", "is", "a", "test", "of", "using", "words"]
  3.  
  4. counter = 1
  5. prev = numbers.pop()
  6.  
  7. while len(numbers) > 0 and counter < 4:
  8. next = numbers.pop()
  9. if prev == next:
  10. counter = counter + 1
  11. else:
  12. counter = 1
  13. prev = next
  14.  
  15. if counter == 4:
  16. print "Found repeated number"
  17. else:
  18. print "No repeated number found"
  19.  
  20.  
Success #stdin #stdout 0.08s 10864KB
stdin
Standard input is empty
stdout
Found repeated number