A subset of Verbal arithmetic

Mathematica

Spaces added for clarity. Not much golfed.
Need to use greek letters because the input letters are treated as symbols.

F[σ_ ,ρ_ ,τ_]:=
 (φ = FromDigits;
 Rest@Union[
   If [ τ * φ@σ == φ@ρ, {φ@σ,φ@ρ} ] /.#& /@
 (Thread[Rule[ σ ∪ ρ , # ] ] & /@ Permutations[Range@9, {Length[σ ∪ ρ] }])])

Usage:

F[{r,e,p,e,a,t},{a,n,d,s,t,o,p},3]
{{819123,2457369}}

F[{s,p,e,e,d},{k,i,l,l,s},3]
{}

F[{t,w,o},{f,o,u,r},2]
{{734,1468},{836,1672},{846,1692},{867,1734},{928,1856},{938,1876}}  

It didn't find any solution for the SPEED+SPEED+SPEED = KILLS ... is that a bug?

Edit

Allowing zero, it finds the following solutions for the SPEED+SPEED+SPEED = KILLS equation:

{{10887,32661},{12667,38001},{23554,70662},
 {23664,70992},{25334,76002},{26334,79002}}

Edit

According to comment:

F[{s, p, e, e, d}, {k, i, l, l, s}, 2]  

{{21776,43552},{21886,43772},{23556,47112},{27331,54662},
 {29331,58662},{42667,85334},{45667,91334},{46557,93114}}

Tags:

Code Golf