A monadic version ((#~(=|.&.":"0)@(*9&+))@i.)2000 0 2 12 44 137 157 167 248 258 1639 1664 1694 -- Bo
--- Den tirs 25/8/09 skrev Sherlock, Ric <[email protected]>: > Fra: Sherlock, Ric <[email protected]> > Emne: Re: [Jprogramming] Finding n where n(n+9) is an palindrome > Til: "Programming forum" <[email protected]> > Dato: tirsdag 25. august 2009 10.24 > Just for fun: > poly=: 0 9 1&p. :. ([: > {:&>@{:"1 [: p. (9 1 ,"0 1~ -)) > 10{. ( (#~ (= |.&.(10&#.^:_1))"0) > &. poly) >:i.12000 > 2 12 44 137 157 167 248 258 1639 1664 > > > > From: Sherlock, Ric > > > > A few more using more @ as requested. > > > > 10 {. (#~ (-: |.)@":"0@(*: + 9&*)) > >:i.12000 > > 2 12 44 137 157 167 248 258 1639 1664 > > > > 10 {. (#~ (-: |.)@":"0@<.@:(0 9 > 1&p.)) >:i.12000 > > 2 12 44 137 157 167 248 258 1639 1664 > > > > 10 {. ({~ [: I. (= > |.&.(10&#.^:_1))"0@(* 9&+)) >:i.12000 > > 2 12 44 137 157 167 248 258 1639 1664 > > > > > From: Sherlock, Ric > > > > > > 10 {. (#~ [: (-: |.)@":"0 ] * > +&9) >:i.12000 > > > 2 12 44 137 157 167 248 258 1639 1664 > > > > > > Or > > > > > > (10 {. ] #~ [: (-: |.)@":"0 ] * > +&9) >:i.12000 > > > 2 12 44 137 157 167 248 258 1639 1664 > > > > > > > From: Ian Gorse > > > > > > > > For example: > > > > 258 is a value of n so that n(n+9) is a > palindrome. > > > > > > > > I set out to find the first 10 numbers that > meet this criteria and > > I > > > > came up with this.. > > > > > > > > 10 {. n #~ ,( ( ] = [: ". [: |. ": ) > ] * +&9 ) "0 ( n =. >: > > > i.12000 > > > > ) > > > > 2 12 44 137 157 167 248 258 1639 1664 > > > > > > > > As you can see, I have already found my > answers but this is just an > > > > educational request. > > > > I am just looking for some alternative > solutions so I can read and > > > > digest the different ways it can be done. > Ideally with the use of > > the > > > > @ conjuction as > > > > I have recently been understanding the > conjuction @ a lot more, as > > I > > > > find the 'flow' of reading the J expression > more fluent. > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > Trænger du til at se det store billede? Kelkoo giver dig gode tilbud på LCD TV! Se her http://dk.yahoo.com/r/pat/lcd ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
