Strings with equal number of 'A's and 'B's

Published: February 21, 2023

A possible solution in J, assuming that the strings are stored in a file called char_count.txt:

p =: 'char_count.txt'
characters =: 'b' freads p
ca =: [: +/ 'A' = ]
cb =: [: +/ 'B' = ]
ceq =: ca = cb
result =: ceq L:0 characters
Go back to the problem.

I would be thrilled to hear from you! Please share your thoughts and ideas with me via email.

Back to Index