+/i.7 is 21 and 7 repetitions of the sum gets you up to 147, so the task is
to figure out which rotations of i.7 has a 9 in its sum prefix.

   +/\"1 |."0 1~i. 7
0  1  3  6 10 15 21
1  3  6 10 15 21 21
2  5  9 14 20 20 21
3  7 12 18 18 19 21
4  9 15 15 16 18 21
5 11 11 12 14 17 21
6  6  7  9 12 16 21

Answer: for rotations by 2, 4, and 6, and corresponding prefix lengths of
3, 2, and 4.  So n is 49+3 2 4, or 52 51 53.

   52 $ 2 |. i.7
2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4
5 6 0 1 2 3 4 5 6 0 1 2 3 4
   +/ 52 $ 2 |. i.7
156

   51 $ 4 |. i.7
4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6
0 1 2 3 4 5 6 0 1 2 3 4 5
   +/ 51 $ 4 |. i.7
156

   53 $ 6 |. i.7
6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1
2 3 4 5 6 0 1 2 3 4 5 6 0 1 2
   +/ 53 $ 6 |. i.7
156




On Sun, Jan 13, 2019 at 11:08 PM Raul Miller <[email protected]> wrote:

> So, like this?
>
>     I.+./|:156=(+/\  7&|)i.1000
>
> 51 52 53
>
>
> Thanks,
>
>
> —
>
> Raul
>
> On Monday, January 14, 2019, 'Skip Cave' via Programming <
> [email protected]> wrote:
>
> > Ric, the problem that got me started thinking about the "find the index
> in
> > the vector/array where the value is x" issue, was a problem posed on
> Quora:
> >
> > The original question as posted: *They are considered to be consecutive
> > natural numbers. The sum of the remainders of those numbers at 7 is 156.
> > What are all the positive values of n?*
> >
> > That wasn't very clearly stated, so I re-phrased the problem to hopefully
> > make it more clear, at least to me: *n consecutive numbers are divided by
> > 7, and their remainders add to 156. What are all possible values of n?  *
> >
> > My brute force solution to this problem was basically to generate
> multiple
> > consecutive sequences of integers, each starting at a new consecutive
> > starting integer. Make the sequences longer than required. Then find the
> > remainders of the numbers in each sequence after dividing by 7. Then find
> > the running sums of the remainders in each sequence. Finally I needed to
> > find the place (index), if any, where the running sum in each sequence
> was
> > equal to 156, which would tell me how long the sequence needed to be, to
> > have the remainders sum to 156. The final answer to the question would be
> > to define what are all the unique sequence lengths are that sum to 156.
> >
> > The URL to the Quora question, my answer, and other answers is:
> >  https://goo.gl/Z3UJGF <https://goo.gl/Z3UJGF>
> >
> > Skip Cave
> > Cave Consulting LLC
> >
> >
> > On Sun, Jan 13, 2019 at 11:15 PM Ric Sherlock <[email protected]> wrote:
> >
> > > Basically you are seeing the result of monadic =
> > >
> > > l2
> > >
> > > 5 2 3 4 6 4 3 5 4 6 7 6
> > >
> > > = l2
> > >
> > > 1 0 0 0 0 0 0 1 0 0 0 0
> > >
> > > 0 1 0 0 0 0 0 0 0 0 0 0
> > >
> > > 0 0 1 0 0 0 1 0 0 0 0 0
> > >
> > > 0 0 0 1 0 1 0 0 1 0 0 0
> > >
> > > 0 0 0 0 1 0 0 0 0 1 0 1
> > >
> > > 0 0 0 0 0 0 0 0 0 0 1 0
> > >
> > > <@I. = l2
> > >
> > > ┌───┬─┬───┬─────┬──────┬──┐
> > >
> > > │0 7│1│2 6│3 5 8│4 9 11│10│
> > >
> > > └───┴─┴───┴─────┴──────┴──┘
> > >
> > >
> > > I think you can simplify your Idot to:
> > >    Idot=: [: <@I. =
> > >
> > > It would be interesting to understand the actual problem you are trying
> > to
> > > solve with Idot.
> > >
> > >
> > > On Mon, Jan 14, 2019 at 5:56 PM 'Skip Cave' via Programming <
> > > [email protected]> wrote:
> > >
> > > > Ok. You have convinced me to go with the empty box as a null
> indicator.
> > > In
> > > > that case, we can make  the Idot verb dyadic, and generalize it:
> > > >
> > > >     Idot =.[:I.&.>[:{="1
> > > >
> > > > l1 =. 1 2 3 4 6 4 3 4 4 6 7 6
> > > >
> > > > 5 Idot l1
> > > >
> > > > ┌┐
> > > >
> > > > ││
> > > >
> > > > └┘
> > > >
> > > > l2 =. 5 2 3 4 6 4 3 5 4 6 7 6
> > > >
> > > > 5 Idot l2
> > > >
> > > > ┌───┐
> > > >
> > > > │0 7│
> > > >
> > > > └───┘
> > > >
> > > > ]m=.|:1 2 3 4,. 2 5 5 5,. 5 4 3 2 ,. 2 3 5 4,. 2 5 4 5
> > > >
> > > > 1 2 3 4
> > > >
> > > > 2 5 5 5
> > > >
> > > > 5 4 3 2
> > > >
> > > > 2 3 5 4
> > > >
> > > > 2 5 4 5
> > > >
> > > > 5 Idot m
> > > >
> > > > ┌┬─────┬─┬─┬───┐
> > > >
> > > > ││1 2 3│0│2│1 3│
> > > >
> > > > └┴─────┴─┴─┴───┘
> > > >
> > > > ]n=.|:2 5 5 5,. 1 2 3 4,. 5 4 3 2 ,. 2 3 5 4,. 2 5 4 5
> > > >
> > > > 2 5 5 5
> > > >
> > > > 1 2 3 4
> > > >
> > > > 5 4 3 2
> > > >
> > > > 2 3 5 4
> > > >
> > > > 2 5 4 5
> > > >
> > > > >m;n
> > > >
> > > > 2 5 5 5
> > > >
> > > > 1 2 3 4
> > > >
> > > > 5 4 3 2
> > > >
> > > > 2 3 5 4
> > > >
> > > > 2 5 4 5
> > > >
> > > > 1 2 3 4
> > > >
> > > > 2 5 5 5
> > > >
> > > > 5 4 3 2
> > > >
> > > > 2 3 5 4
> > > >
> > > > 2 5 4 5
> > > >
> > > >
> > > > 5 Idot > m;n
> > > >
> > > > ┌─────┬─────┬─┬─┬───┐
> > > >
> > > > │1 2 3│ │0│2│1 3│
> > > >
> > > > ├─────┼─────┼─┼─┼───┤
> > > >
> > > > │ │1 2 3│0│2│1 3│
> > > >
> > > > └─────┴─────┴─┴─┴───┘
> > > >
> > > >
> > > > NB. It's interesting what the monadic use of Idot does:
> > > >
> > > >
> > > > Idot l1
> > > >
> > > > ┌─┬─┬───┬───────┬──────┬──┐
> > > >
> > > > │0│1│2 6│3 5 7 8│4 9 11│10│
> > > >
> > > > └─┴─┴───┴───────┴──────┴──┘
> > > >
> > > > Idot l2
> > > >
> > > > ┌───┬─┬───┬─────┬──────┬──┐
> > > >
> > > > │0 7│1│2 6│3 5 8│4 9 11│10│
> > > >
> > > > └───┴─┴───┴─────┴──────┴──┘
> > > >
> > > > Idot m ┌─┬─────┬─┬─┐ │0│1 │2│3│ ├─┼─────┼─┼─┤ │0│1 2 3│ │ │
> > ├─┼─────┼─┼─┤
> > > > │0│1 │2│3│ ├─┼─────┼─┼─┤ │0│1 │2│3│ ├─┼─────┼─┼─┤ │0│1 3 │2│ │
> > > > └─┴─────┴─┴─┘
> > > >
> > > > Idot n
> > > >
> > > > ┌─┬─────┬─┬─┐
> > > >
> > > > │0│1 2 3│ │ │
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 │2│3│
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 │2│3│
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 │2│3│
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 3 │2│ │
> > > >
> > > > └─┴─────┴─┴─┘
> > > >
> > > > Idot >m;n
> > > >
> > > > ┌─┬─────┬─┬─┐
> > > >
> > > > │0│1 │2│3│
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 2 3│ │ │
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 │2│3│
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 │2│3│
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 3 │2│ │
> > > >
> > > > └─┴─────┴─┴─┘
> > > >
> > > >
> > > > ┌─┬─────┬─┬─┐
> > > >
> > > > │0│1 2 3│ │ │
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 │2│3│
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 │2│3│
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 │2│3│
> > > >
> > > > ├─┼─────┼─┼─┤
> > > >
> > > > │0│1 3 │2│ │
> > > >
> > > > └─┴─────┴─┴─┘
> > > >
> > > > Can you explain what's going on here?
> > > >
> > > >
> > > > Skip Cave
> > > > Cave Consulting LLC
> > > >
> > > >
> > > > On Sun, Jan 13, 2019 at 8:02 PM Ric Sherlock <[email protected]>
> > wrote:
> > > >
> > > > > Depending on what you are trying to acheive, I think I'd represent
> > the
> > > > lack
> > > > > of a match in a row as an empty rather than a _1:
> > > > >
> > > > > <@I."1 ] 5=m
> > > > >
> > > > > ┌┬─┬─┬─┐
> > > > >
> > > > > ││3│0│2│
> > > > >
> > > > > └┴─┴─┴─┘
> > > > >
> > > > >
> > > > > Of course if you need the _1 then you can transform the above
> > > > >
> > > > > ;@([: (a:=])`((<_1),:~ ])} <@I."1) 5 = m
> > > > >
> > > > >
> > > > > On Mon, Jan 14, 2019 at 10:42 AM 'Skip Cave' via Programming <
> > > > > [email protected]> wrote:
> > > > >
> > > > > > What I would really like is for I. to return a _1 whenever there
> is
> > > no
> > > > 1
> > > > > in
> > > > > > the match array, since there cannot be a negative index:
> > > > > >
> > > > > > I.5=1 2 3 4 6 4 3 4 4 6 7 6
> > > > > >
> > > > > > 4 8 10
> > > > > >
> > > > > > Idot 5=1 2 3 4 6 4 3 4 4 6 7 6
> > > > > >
> > > > > > _1
> > > > > >
> > > > > >
> > > > > > ]m=.|:1 2 3 4,. 2 3 4 5,. 5 4 3 2 ,. 2 3 5 4
> > > > > >
> > > > > > 1 2 3 4
> > > > > >
> > > > > > 2 3 4 5
> > > > > >
> > > > > > 5 4 3 2
> > > > > >
> > > > > > 2 3 5 4
> > > > > >
> > > > > > 5=m
> > > > > >
> > > > > > 0 0 0 0
> > > > > >
> > > > > > 0 0 0 1
> > > > > >
> > > > > > 1 0 0 0
> > > > > >
> > > > > > 0 0 1 0
> > > > > >
> > > > > > ,Idot .5=m
> > > > > >
> > > > > > _1 3 0 2
> > > > > >
> > > > > >
> > > > > > Can a verb Idot be designed, that does this?
> > > > > >
> > > > > > Skip Cave
> > > > > > Cave Consulting LLC
> > > > > >
> > > > > >
> > > > > > On Sun, Jan 13, 2019 at 2:41 PM Henry Rich <[email protected]
> >
> > > > wrote:
> > > > > >
> > > > > > > Right.  Prefer (I.@:= ,) to I.@,@:= since it uses special
> code.
> > > > > > >
> > > > > > > Henry Rich
> > > > > > >
> > > > > > > On 1/13/2019 2:54 PM, 'Mike Day' via Programming wrote:
> > > > > > > > You often see this sort of thing, returning pairs of indices
> of
> > > all
> > > > > > > occurrences:
> > > > > > > >
> > > > > > > >     5 ($@] #.inv I.@,@:=) |: 1 2 3 4,. 2 3 4 5,. 5 4 3 2 ,.
> 2
> > 3
> > > 5
> > > > 4
> > > > > > > > 1 3
> > > > > > > > 2 0
> > > > > > > > 3 2
> > > > > > > >
> > > > > > > > You can obviously get the row indices using {:”1 or some
> such,
> > > and
> > > > > you
> > > > > > > can of course make the bracketed code a named dyadic verb,
> > > > > > > >
> > > > > > > > Cheers,
> > > > > > > >
> > > > > > > > Mike
> > > > > > > >
> > > > > > > >
> > > > > > > > Sent from my iPad
> > > > > > > >
> > > > > > > >> On 13 Jan 2019, at 17:55, 'Skip Cave' via Programming <
> > > > > > > [email protected]> wrote:
> > > > > > > >>
> > > > > > > >> I know I can find the location (index) of a specific integer
> > in
> > > a
> > > > > > > vector of
> > > > > > > >> integers using I.
> > > > > > > >>
> > > > > > > >> I.5=1 2 3 4 5 4 3 4 5 6 5 6
> > > > > > > >>
> > > > > > > >> 4 8 10
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> So I want to find the row index of a specific integer in an
> > > array
> > > > of
> > > > > > > >> integers:
> > > > > > > >>
> > > > > > > >> |:1 2 3 4,. 2 3 4 5,. 5 4 3 2 ,. 2 3 5 4
> > > > > > > >>
> > > > > > > >> 1 2 3 4
> > > > > > > >>
> > > > > > > >> 2 3 4 5
> > > > > > > >>
> > > > > > > >> 5 4 3 2
> > > > > > > >>
> > > > > > > >> 2 3 5 4
> > > > > > > >>
> > > > > > > >> 5=|:1 2 3 4,. 2 3 4 5,. 5 4 3 2 ,. 2 3 5 4
> > > > > > > >>
> > > > > > > >> 0 0 0 0
> > > > > > > >>
> > > > > > > >> 0 0 0 1
> > > > > > > >>
> > > > > > > >> 1 0 0 0
> > > > > > > >>
> > > > > > > >> 0 0 1 0
> > > > > > > >>
> > > > > > > >> ,I. 5=|:1 2 3 4,. 2 3 4 5,. 5 4 3 2 ,. 2 3 5 4
> > > > > > > >>
> > > > > > > >> 0 3 0 2
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> The first zero indicates that there is no 5 in the first
> row.
> > > The
> > > > > > second
> > > > > > > >> zero gives the index of the 5 in the third row. How can I
> tell
> > > > > whether
> > > > > > > the
> > > > > > > >> zero is an index, or a null indicator?
> > > > > > > >>
> > > > > > > >> Skip
> > > > > > > >>
> > > > > ------------------------------------------------------------
> > ----------
> > > > > > > >> For information about J forums see
> > > > > > http://www.jsoftware.com/forums.htm
> > > > > > > >
> > > > > ------------------------------------------------------------
> > ----------
> > > > > > > > For information about J forums see
> > > > > http://www.jsoftware.com/forums.htm
> > > > > > >
> > > > > > >
> > > > > > > ---
> > > > > > > This email has been checked for viruses by AVG.
> > > > > > > https://www.avg.com
> > > > > > >
> > > > > > >
> > > >
> ----------------------------------------------------------------------
> > > > > > > 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
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to