ABC problem: Difference between revisions

m
Line 1,470:
 
We can classify possibilities by counting how many of each letter occur. If a candidate has at least as many of the required letters as a test case constructed from the word itself, it's a valid candidate.
 
For example:
 
<lang J> Blocks canform 0{::ExampleWords
1
word
A
need
2
relevant
NA
AN
candidates
ANA
ANN
AAA
AAN</lang>
 
Here, the word is simple 'A', and we have two blocks to consider: AN and NA. So we form all possible combinations of the letters of those two bocks, prefix each of them with our word and test whether any of them contain two copies of the letters of our word. (As it happens, all of the candidates are valid, for this trivial example.)
 
=={{header|Java}}==
{{trans|D}}
6,962

edits