Hi gc,
I realized we all posted solutions without giving you feedback as requested
Some feedback:
1. My style is to eliminate parentheses as I find it harder to see the
substance of the function
(# - [: +:@(+/) '('&i.) '((()'
is equivalent but with fewer parentheses
I sometimes prefer trains over bond - again, just style
(# - [: +:@(+/) '(' i. ]) '((()'
2. The usage of i. is not intuitive as you are seeking 1 if the character
is ). I would be more explicit about that
(# - [: +:@(+/) ')' = ]) '((()'
3. In my version, I would remove the cap
(# - ')' +:@(+/)@:= ]) '((()'
4. I considered eliminating the ] but that resulted in more parentheses
and I thought it was less clear
(# - +: @ (+/) @: (=&')') ) '((()'
but we can move the bond to the right and parentheses aren't needed around
it
(# - +: @ (+/) @: =&')' ) '((()'
compared with
#-(+:@(+/@('('&i.)))
I think this would be my final restyling of the concept of your version
- sent from my mobile and tested with jandroid so not tested thoroughly
On Dec 1, 2015 5:07 PM, "Geoff Canyon" <[email protected]> wrote:
> Spoiler (my solution, looking for feedback)
> .
> .
> .
> .
> .
> .
> .
> .
>
> F =: #-(+:@(+/@('('&i.)))
>
>
> If S is the string from the site, then
>
>
> F S
>
> returns the ending floor (the first part of the challenge).
>
>
> Any suggestions on improving the syntax are welcome, I only dabble in J.
>
>
> thx
>
>
> gc
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm