Yes, one of the Quora answer posts for this challenge pointed this out as well, so I tried that approach. Not being too competent with the use of & @, I tried:
13|*/13|/19 29 59 79 89 109 119 139 149 179 199 4 I got the answer, but I need a course on the use of @ and & in order to tighten up my code. Skip Skip Cave Cave Consulting LLC On Mon, Sep 18, 2017 at 12:47 PM, Roger Hui <rogerhui.can...@gmail.com> wrote: > This particular problem can be solved without resort to extended > precision. Use multiplication mod 13, that is, find the remainder at each > step rather than waiting until the end: > > 13&|@* / 19 29 59 79 89 109 119 139 149 179 199 > 4 > > > On Mon, Sep 18, 2017 at 10:00 AM, Skip Cave <s...@caveconsulting.com> > wrote: > > > People posting problems on Quora are typically expecting an explicit > > algebraic formula solution to their problem, though they never > explicitly > > state that requirement. The posted Quora problems often involve very > large > > numbers, which the poster expects will prevent solutions from using a > > calculator or computer program to solve. In most cases, J's extended > > precision arithmetic can handle those large numbers quite handily. > > > > Typical Quora problem: > > How would you calculate the remainder of {19 × 29 × 59 × 79 × 89 × 109 × > > 119 × 139 × 149 × 179 × 199} divided by 13? > > <https://www.quora.com/How-would-you-calculate-the- > > remainder-of-19-%C3%97-29-%C3%97-59-%C3%97-79-%C3%97-89-%C3% > > 97-109-%C3%97-119-%C3%97-139-%C3%97-149-%C3%97-179-%C3%97- > > 199-divided-by-13> > > > > My answer: > > > > Using the J programming language (Jsoftware.com) > > > > 13|*/19 29 59 79 89 109 119 139 149 179 199x > > > > 4 > > > > So the answer is 4 > > > > > > Skip Cave > > Cave Consulting LLC > > > > On Mon, Sep 18, 2017 at 6:17 AM, Raul Miller <rauldmil...@gmail.com> > > wrote: > > > > > That has been characteristic of Project Euler but Quora Challenges are > > > new to me. > > > > > > Anyways, if the problem expects to answers work with precisions well > > > beyond measurable limits, that should be stated as a part of the > > > problem. > > > > > > Thanks, > > > > > > -- > > > Raul > > > > > > > > > On Sun, Sep 17, 2017 at 2:05 PM, Skip Cave <s...@caveconsulting.com> > > > wrote: > > > > The fact that the problem is a Quora challenge is exactly the point. > > It's > > > > like if someone asks your for the square root of 75976307044. Yes, > > there > > > is > > > > a manual process that one can use to compute the square root. But why > > > spend > > > > all that time when one can type %:75976307044 or use a hand-held > > > > calculator, and get the answer instantly. As an engineer, speed and > > > > accuracy are more important than going through a complicated manual > > > process > > > > to get that same answer. > > > > > > > > I post lots of these J solutions on Quora to remind folks of that > fact. > > > > It's not that I'm against knowing the manual approach to the > solutions. > > > > It's just that the more tools we have to make hard problems easier, > the > > > > better we can solve even harder problems. > > > > > > > > Skip Cave > > > > Cave Consulting LLC > > > > > > > > On Sun, Sep 17, 2017 at 12:28 PM, Erling Hellenäs < > > > erl...@erlinghellenas.se> > > > > wrote: > > > > > > > >> Strange things happen here. It works but give incorrect results. I > > just > > > >> changed F to lower case to put it through my tests. Not sure what > > might > > > >> happen here. I have J 8.04 on this machine. 64 bit. > > > >> I never doubted that p: was good. I just thought that since it was a > > > Quora > > > >> challenge that using p: would not be a good idea, since the > algorithm > > > used > > > >> in p: is not known to the audience. It also seemed like some kind > of > > > >> cheating, like using a subroutine someone else wrote to solve half > the > > > >> problem. > > > >> Well, I also thought p: would have to generate the array of primes > for > > > >> each call, but it's obviously not the case. There is a formula which > > > does > > > >> the trick? Or a hash table of primes? > > > >> > > > >> thru=: <. + >:@>. i.@- <. > > > >> > > > >> biggap=: {~ 0 1 - [: (i. <./) 2 -/\ ] > > > >> > > > >> f=: [: thru/ 1 _1 + [: biggap <./ >. >./ <. thru&.(p:inv) > > > >> > > > >> s=: 10 f 100 > > > >> > > > >> s > > > >> > > > >> 20 21 22 > > > >> > > > >> >./90 91 92 93 94 95 96 = s > > > >> > > > >> |length error: scriptd > > > >> > > > >> | >./90 91 92 93 94 95 96 =s > > > >> > > > >> |[-5] j:\j64-803-user\projects\quoraraul.ijs > > > >> > > > >> inv > > > >> > > > >> ^:_1 > > > >> > > > >> > > > >> Cheers, > > > >> > > > >> Erling > > > >> > > > >> On 2017-09-17 17:38, Raul Miller wrote: > > > >> > > > >>> Yes. :) > > > >>> > > > >>> When J provides a mechanism for something it is usually worth > trying. > > > >>> Sometimes you can write something faster, but usually J's approach > > > >>> will be useful. > > > >>> > > > >>> For example, in this case, consider this approach: > > > >>> > > > >>> thru=: <. + >:@>. i.@- <. > > > >>> biggap=: {~ 0 1 - [: (i. <./) 2 -/\ ] > > > >>> F=: [: thru/ 1 _1 + [: biggap <./ >. >./ <. thru&.(p:inv) > > > >>> > > > >>> There will be cases where another approach could be more efficient, > > > >>> but it performs reasonably well. > > > >>> > > > >>> Thanks, > > > >>> > > > >>> > > > >> ------------------------------------------------------------ > > ---------- > > > >> For information about J forums see http://www.jsoftware.com/ > > forums.htm > > > >> > > > > ------------------------------------------------------------ > ---------- > > > > For information about J forums see http://www.jsoftware.com/ > forums.htm > > > ---------------------------------------------------------------------- > > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm