জেলি , 18 13 10 বাইট
×⁵RDP$€io-
এটি অনলাইন চেষ্টা করুন!
13-বাইট সমাধান:
×⁵RDP$€iµ’¹¬?
এটি অনলাইন চেষ্টা করুন!
ইনপুট সহ ব্যাখ্যা 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
18-বাইট সমাধান:
D×/
×⁵RÇ€i
Ç⁾-1¹¬?
এটি অনলাইন চেষ্টা করুন!
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).
শেষ লিঙ্কটি কেবলমাত্র 0 (জেলির ডিফল্ট মিথ্যা মান, কারণ সমস্ত তালিকাগুলি এক-সূচকযুক্ত) -1 এর সাথে প্রতিস্থাপন করবে। আপনি যদি 0 টি ওকে ভুয়া মান বিবেচনা করেন তবে প্রোগ্রামটি 8 বাইট ।
1দান1করা একটি গুরুত্বপূর্ণ পরীক্ষার কেস।