1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | local read, write = io.read, io.write local num, nl = '*n', '\n' local t t = read(num) while t > 0 do t = t-1 local str str = read(num) local l = string.len(str) local i,count = 0,0 while i < l do local j = 0 while j < l do if string.byte(str,i) == string.byte(str,j) then count = count+1 end j = j + 1 end i = i + 1 end write(count) write("\n") end |
bG9jYWwgcmVhZCwgd3JpdGUgPSBpby5yZWFkLCBpby53cml0ZQpsb2NhbCBudW0sIG5sID0gJypuJywgJ1xuJwpsb2NhbCB0Cgp0ID0gcmVhZChudW0pCgp3aGlsZSB0ID4gMCBkbwoJdCA9IHQtMQoJbG9jYWwgc3RyCglzdHIgPSByZWFkKG51bSkKCQoJCglsb2NhbCBsID0gc3RyaW5nLmxlbihzdHIpCglsb2NhbCBpLGNvdW50ID0gMCwwCgl3aGlsZSBpIDwgbCBkbwoJCWxvY2FsIGogPSAwCgkJd2hpbGUgaiA8IGwgZG8KCQkJaWYgc3RyaW5nLmJ5dGUoc3RyLGkpID09IHN0cmluZy5ieXRlKHN0cixqKSB0aGVuIGNvdW50ID0gY291bnQrMQoJCQllbmQKCQlqID0gaiArIDEKCQllbmQKCQlpID0gaSArIDEKCWVuZAoJd3JpdGUoY291bnQpCgl3cml0ZSgiXG4iKQplbmQ=
-
upload with new input
-
result: Success time: 0.02s memory: 2544 kB returned value: 0
2 1234 777
4 5
-
result: Success time: 0.01s memory: 2544 kB returned value: 0
2 123 777
3 5



