 # Getting WA for STONES problem after passing all the test cases and some tested by me as well

Hey, can someone plaese tell me whats wrong in this code,

for the problem https://www.codechef.com/problems/STONES

for _ in range(int(input())):
s1=list(dict.fromkeys(list(input())))
s2=list(dict.fromkeys(list(input())))
count=0
for i in range(len(s1)):
if s1[i] in s2:
count+=1
print(count)

The question is a little ambiguous, but according to a random AC solution, the answer to

``````1
a
aaaaaaaaaaaaaaaaa
``````

should be `17`.

yep, got it!!
thanks

1 Like

@knight_nikhil You don’t need to use dictionaries to solve this problem. Refer to the following code:

``````def compute_total_jewels_present(jewel_stones, mined_stones):
jewel_count = 0
for stone in mined_stones:
if stone in jewel_stones:
jewel_count += 1
return jewel_count

def main():
for test_case in range(int(input())):
jewel_stones = input()
mined_stones = input()
print(compute_total_jewels_present(jewel_stones, mined_stones))

if __name__ == "__main__":
main()
``````

Thanks for reading.
Peace 