是啊是啊.那两道数字题不知道有了结果没有
Ans...
1、用Mathematica算
Off[General::"spell1"]
chars = Characters /@ ToLowerCase /@ {"WWWDOT", "GOOGLE", "DOTCOM"};
uchars = Union[Flatten[chars]];
eqn = First[#] - Plus @@ Rest[#] &[FromDigits[#, 10] & /@ chars] == 0;
Timing[soln =
Select[Permutations[Range[0, 9]], eqn /. Thread[uchars -> Most[#]] &]]
结果:{271.891 Second, {{4,5,3,1,0,6,8,9,7,2},{4,5,6,1,0,3,8,9,7,2}}}
Thread[uchars -> Most[#]] & /@ soln
结果:{{c -> 4, d -> 5, e -> 3, g -> 1, l -> 0, m -> 6, o -> 8, t -> 9,
w -> 7}, {c -> 4, d -> 5, e -> 6, g -> 1, l -> 0, m -> 3, o -> 8,
t -> 9, w -> 7}}
所以:777589-188106=589483 或者 777589-188103=589486
3、312211
这个比较火星,应该不是google原创。
Off[General::"spell1"]
chars = Characters /@ ToLowerCase /@ {"WWWDOT", "GOOGLE", "DOTCOM"};
uchars = Union[Flatten[chars]];
eqn = First[#] - Plus @@ Rest[#] &[FromDigits[#, 10] & /@ chars] == 0;
Timing[soln =
Select[Permutations[Range[0, 9]], eqn /. Thread[uchars -> Most[#]] &]]
结果:{271.891 Second, {{4,5,3,1,0,6,8,9,7,2},{4,5,6,1,0,3,8,9,7,2}}}
Thread[uchars -> Most[#]] & /@ soln
结果:{{c -> 4, d -> 5, e -> 3, g -> 1, l -> 0, m -> 6, o -> 8, t -> 9,
w -> 7}, {c -> 4, d -> 5, e -> 6, g -> 1, l -> 0, m -> 3, o -> 8,
t -> 9, w -> 7}}
所以:777589-188106=589483 或者 777589-188103=589486
3、312211
这个比较火星,应该不是google原创。