fork download
  1. local read, write = io.read, io.write
  2. local num, nl = '*n', '\n'
  3. local t
  4.  
  5. t = read(num)
  6.  
  7. while t > 0 do
  8. t = t-1
  9. local str
  10. str = read(num)
  11.  
  12.  
  13. local l = string.len(str)
  14. local i,count = 0,0
  15. while i < l do
  16. local j = 0
  17. while j < l do
  18. if string.byte(str,i) == string.byte(str,j) then count = count+1
  19. end
  20. end
  21. end
  22. write(count)
  23. write("\n")
  24. end
Time limit exceeded #stdin #stdout 5s 2540KB
stdin
2
123
777
stdout
Standard output is empty