Product by I., S.(I like this and, not to be discouraged, wish input samples were longer and consistent i.e. either with or without the last LF.)

    4 :'wd<.+/(#(%*/)&:!  #/.~)@}."1(#~1={."1);<@(1|."1}.,~"1{.(],.%){.(]#~0=|~)              9(-i.)@<.{:)"1@;^:y x'/@do      ^:(*@#);._1(,stdin)LF  NB. OK within 32-bit signed int for x<=12 & N>=1
NB. 4 :'wd  +/(#(%*/)&:!]@#/.~)@}."1(#~1={."1);<@(1|."1}.,~"1{.(],.%){.(]#~0=|~)i.@{:@q:@{.-.~9(-i.)@<.{:)"1@;^:y x'/@do@,&'x'^:(*@#);._1(,stdin)LF  NB. faster; arbitrary precision
NB. all problems/non-0 answers for given x; brute force, slow, & large; practical x<=6 on my PC
NB. 1!:2&2"1 ": 2&A."1 x,. /:~ ({.,#)/.~ */"1 (*/@}.}. (#: i.@(*/))) 10#~ x=. 3

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page