Ah, wait now I get it, you don't want to brute force, but find if there is any possible solution to the problem.
Then I would not use things as Count and DeleteDuplicates.
Basically you want to check if each element of A is equal to any element of B.
Based on you description of the two cases that should resolve to True and False you also define that each element of B is present in A. else the second case also has a solution.
In[1]:= findSolution[A_, B_, n_ : 1] :=
Block[{var, func, memberAofB, memberBofA, elem, ex, res, sol},
(*get unique variables*)
var = DeleteDuplicates[Flatten[Variables /@ Join[A, B]]];
(*define functions, each has to be >0*)
func = And @@ (# > 0 & /@ Join[A, B]);
(*define that each element of A has to be equal to at least one \
element of B*)
memberAofB = And @@ ((am = #; Or @@ ((am == #) & /@ B)) & /@ A);
(*define that each element of B has to be equal to at least one \
element of A*)
(*was not in the description but seems to be needed for second \
solution to be False*)
memberBofA = And @@ ((bm = #; Or @@ ((bm == #) & /@ A)) & /@ B);
(*define that all variables are positive Integers*)
elem = Element[Alternatives @@ var, PositiveIntegers];
(*define exist*)
ex = Exists[#, Element[Alternatives @@ var, PositiveIntegers],
func && memberAofB && memberBofA] &[var];
(*resolve solution*)
res = Resolve[ex, PositiveIntegers];
(*if solution exists find solution*)
sol = If[res,
sol =
FindInstance[func && memberAofB && memberBofA && elem, #, n] &[
var];
{Column[Thread[sol -> ({A, B} /. sol)]]},
None
];
{res, sol}
]
In[2]:= findSolution[{a - b, c}, {x, y, z}]
findSolution[{a - b, c}, {x, y, z}, 2]
findSolution[{a - b, c}, {x, y, z}, 10]
findSolution[{a - b, b - c}, {a - c, x}, 1]
Out[2]= {True, { \!\(\*
TagBox[GridBox[{
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "3"}], ",",
RowBox[{"b", "->", "1"}], ",",
RowBox[{"c", "->", "2"}], ",",
RowBox[{"x", "->", "2"}], ",",
RowBox[{"y", "->", "2"}], ",",
RowBox[{"z", "->", "2"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"2", ",", "2"}], "}"}], ",",
RowBox[{"{",
RowBox[{"2", ",", "2", ",", "2"}], "}"}]}], "}"}]}]}
},
DefaultBaseStyle->"Column",
GridBoxAlignment->{"Columns" -> {{Left}}},
GridBoxItemSize->{
"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}],
"Column"]\) }}
Out[3]= {True, { \!\(\*
TagBox[GridBox[{
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "180"}], ",",
RowBox[{"b", "->", "1"}], ",",
RowBox[{"c", "->", "179"}], ",",
RowBox[{"x", "->", "179"}], ",",
RowBox[{"y", "->", "179"}], ",",
RowBox[{"z", "->", "179"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"179", ",", "179"}], "}"}], ",",
RowBox[{"{",
RowBox[{"179", ",", "179", ",", "179"}], "}"}]}], "}"}]}]},
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "31"}], ",",
RowBox[{"b", "->", "1"}], ",",
RowBox[{"c", "->", "30"}], ",",
RowBox[{"x", "->", "30"}], ",",
RowBox[{"y", "->", "30"}], ",",
RowBox[{"z", "->", "30"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"30", ",", "30"}], "}"}], ",",
RowBox[{"{",
RowBox[{"30", ",", "30", ",", "30"}], "}"}]}], "}"}]}]}
},
DefaultBaseStyle->"Column",
GridBoxAlignment->{"Columns" -> {{Left}}},
GridBoxItemSize->{
"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}],
"Column"]\) }}
Out[4]= {True, { \!\(\*
TagBox[GridBox[{
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "251"}], ",",
RowBox[{"b", "->", "40"}], ",",
RowBox[{"c", "->", "211"}], ",",
RowBox[{"x", "->", "211"}], ",",
RowBox[{"y", "->", "211"}], ",",
RowBox[{"z", "->", "211"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"211", ",", "211"}], "}"}], ",",
RowBox[{"{",
RowBox[{"211", ",", "211", ",", "211"}], "}"}]}], "}"}]}]},
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "94"}], ",",
RowBox[{"b", "->", "1"}], ",",
RowBox[{"c", "->", "93"}], ",",
RowBox[{"x", "->", "93"}], ",",
RowBox[{"y", "->", "93"}], ",",
RowBox[{"z", "->", "93"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"93", ",", "93"}], "}"}], ",",
RowBox[{"{",
RowBox[{"93", ",", "93", ",", "93"}], "}"}]}], "}"}]}]},
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "464"}], ",",
RowBox[{"b", "->", "41"}], ",",
RowBox[{"c", "->", "423"}], ",",
RowBox[{"x", "->", "423"}], ",",
RowBox[{"y", "->", "423"}], ",",
RowBox[{"z", "->", "423"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"423", ",", "423"}], "}"}], ",",
RowBox[{"{",
RowBox[{"423", ",", "423", ",", "423"}], "}"}]}], "}"}]}]},
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "452"}], ",",
RowBox[{"b", "->", "1"}], ",",
RowBox[{"c", "->", "451"}], ",",
RowBox[{"x", "->", "451"}], ",",
RowBox[{"y", "->", "451"}], ",",
RowBox[{"z", "->", "451"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"451", ",", "451"}], "}"}], ",",
RowBox[{"{",
RowBox[{"451", ",", "451", ",", "451"}], "}"}]}], "}"}]}]},
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "90"}], ",",
RowBox[{"b", "->", "89"}], ",",
RowBox[{"c", "->", "1"}], ",",
RowBox[{"x", "->", "1"}], ",",
RowBox[{"y", "->", "1"}], ",",
RowBox[{"z", "->", "1"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"1", ",", "1"}], "}"}], ",",
RowBox[{"{",
RowBox[{"1", ",", "1", ",", "1"}], "}"}]}], "}"}]}]},
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "112"}], ",",
RowBox[{"b", "->", "1"}], ",",
RowBox[{"c", "->", "1"}], ",",
RowBox[{"x", "->", "111"}], ",",
RowBox[{"y", "->", "1"}], ",",
RowBox[{"z", "->", "1"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"111", ",", "1"}], "}"}], ",",
RowBox[{"{",
RowBox[{"111", ",", "1", ",", "1"}], "}"}]}], "}"}]}]},
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "859"}], ",",
RowBox[{"b", "->", "97"}], ",",
RowBox[{"c", "->", "762"}], ",",
RowBox[{"x", "->", "762"}], ",",
RowBox[{"y", "->", "762"}], ",",
RowBox[{"z", "->", "762"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"762", ",", "762"}], "}"}], ",",
RowBox[{"{",
RowBox[{"762", ",", "762", ",", "762"}], "}"}]}], "}"}]}]},
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "636"}], ",",
RowBox[{"b", "->", "1"}], ",",
RowBox[{"c", "->", "635"}], ",",
RowBox[{"x", "->", "635"}], ",",
RowBox[{"y", "->", "635"}], ",",
RowBox[{"z", "->", "635"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"635", ",", "635"}], "}"}], ",",
RowBox[{"{",
RowBox[{"635", ",", "635", ",", "635"}], "}"}]}], "}"}]}]},
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "936"}], ",",
RowBox[{"b", "->", "9"}], ",",
RowBox[{"c", "->", "37"}], ",",
RowBox[{"x", "->", "37"}], ",",
RowBox[{"y", "->", "927"}], ",",
RowBox[{"z", "->", "927"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"927", ",", "37"}], "}"}], ",",
RowBox[{"{",
RowBox[{"37", ",", "927", ",", "927"}], "}"}]}], "}"}]}]},
{
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"a", "->", "44"}], ",",
RowBox[{"b", "->", "43"}], ",",
RowBox[{"c", "->", "1"}], ",",
RowBox[{"x", "->", "1"}], ",",
RowBox[{"y", "->", "1"}], ",",
RowBox[{"z", "->", "1"}]}], "}"}], "->",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"1", ",", "1"}], "}"}], ",",
RowBox[{"{",
RowBox[{"1", ",", "1", ",", "1"}], "}"}]}], "}"}]}]}
},
DefaultBaseStyle->"Column",
GridBoxAlignment->{"Columns" -> {{Left}}},
GridBoxItemSize->{
"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}],
"Column"]\) }}
Out[5]= {False, None}