fork download
  1. s1 = "Some string".split('')
  2. s2 = "Some strong".split('')
  3.  
  4. s2len = s2.length
  5. same = 0
  6.  
  7. s1.length.times do |i|
  8. if i > s2len
  9. break
  10. end
  11.  
  12. if s1[i] == s2[i]
  13. same += 1
  14. end
  15. end
  16.  
  17. puts "Same characters: #{same}/#{s1.length}"
Success #stdin #stdout 0s 8200KB
stdin
Standard input is empty
stdout
Same characters: 10/11