Geléia , 18 13 10 bytes
×⁵RDP$€io-
Experimente online!
Solução de 13 bytes:
×⁵RDP$€iµ’¹¬?
Experimente online!
Explicação com entrada N:
׳R create a range from 1 to N * 100 (replace ³ with ⁵ for a faster execution time)
DP$ define a function ($) to get the product of the digits of a number,
€ apply that function to each element in the list,
iµ get the index of the input N in the list (or 0 if it's not there), and yeild it as the input to the next link,
’¹¬? conditional: if the answer is 0, then subtract one to make it -1, otherwise, yeild the answer
Solução de 18 bytes:
D×/
×⁵RÇ€i
Ç⁾-1¹¬?
Experimente online!
D×/ product of digits function, takes input M
D split M into digits,
×/ reduce by multiplication (return product of digits)
×⁵RÇ€i range / index function
×⁵R make a range from 1 to N*10,
Ç€ run the above function on each of the range elements,
i get the index of N in the result, or 0 if it's not there
Ç⁾-1¹¬? main function:
Ç ¬? run the line above and check if the answer is null (0)
⁾-1 if it is, return "-1",
¹ otherwise, return the answer (identity function).
O último link é apenas para substituir 0 (valor falsey padrão de Jelly, como todas as listas são indexadas por um) por -1. Se você considerar 0 um valor falsey OK, o programa será 8 bytes .
1dar1é um caso de teste importante.