Output for other arguments for tricnt

   tricnt&> 54+i.6
47.75 55.75 51.75 61 55.75 65

???


Here's an algebraic solution:

telz=: 3 :0
zx=. <.-:y
zm=. 1+<.y%3
+/>.-:(1&{-y-+/) (,:<:)zm+i.1+zx-zm
)

   telz&> 54+i.7
61 56 65 61 70 65 75

or tacit (mind line wrapping)

+/@:([: >.@-: (({:@]-(-+/)) [:(,: <:) >:@<.@%&3 ([+i.@>:@-~)<.@-:))&> 54+i.7
61 56 65 61 70 65 75




On 27-05-13 17:08, Olivier N. wrote:
My son said that one of the students arrived at the correct answer of 61
without a computer. I can't believe this given the time it would require to
go through the answer space via pencil and paper (28^3). Is there a closed
form solution, or algebraic solution?
Yes, there is. All in all, it was quite easy to find but the
corr-ection factor that depends on the parities of zmin and zmax.
Enjoy:

tricnt =: 3 : 0
   zmin =. 1+>.y%3
   zmax =. -<.1-y%2
   sumz =. zmin+zmax
   corr =. (_1)^(1-2|zmin)*(1-2|sumz)
   (_1r4*corr) + (1+zmax-zmin) * (-(y+1)%2) + (3*sumz%4) - 1r4
)

Not being confident yet with J syntax,
the last line is overfull of parentheses.
Sorry about this.

Regards.
----------------------------------------------------------------------
For information about J forums seehttp://www.jsoftware.com/forums.htm

--
Met vriendelijke groet,
@@i = Arie Groeneveld

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to