K question...

Content-Disposition: inlineHello,

I’m trying to understand Arthur’s famous two-liner Sudoku solver.

I’m still in the first expression:
p,:3/:_(p:9:!81)%3

What does 3/: and 9: does? According to what  I know the form of each-left and each right is:
x f /: l
x f : l

where f is a dyadic verb..

Any insight?

Thanks,
  Yoel

joel,: and /: are vs and sv functions in q.they have to many functionalities depending on left argument.in this particular examaple, it expands the radices of 9 over this !81vector.this used to work on any shape of the y arg in k3.in q works on specific arguments only.the reverse 3/: is evaluating y in radices of x.felix

Hi,q version may be easier to read:p,:3 sv floor(p:9 vs til 81)%3Cheers,nmlOn May 18, 1:21?pm, felix <felix.lu…> wrote:> joel,>> : and /: are vs and sv functions in q.> they have to many functionalities depending on left argument.>> in this particular examaple, it expands the radices of 9 over this !81> vector.> this used to work on any shape of the y arg in k3.> in q works on specific arguments only.>> the reverse 3/: is evaluating ?y in radices of x.>> felix</felix.lu…>

Yes it is. Thanks!

Hi nml,

The reference on code.kx.com only does not mentions what is vs function when the LHS argument is a number. The only options are a character, 0b, 0x0 and `.

What is its function with a number? It also seems to work only with 9 as an argument..

Yoel

hi Yoel,

afaik vs function should work as following (for left operant int,
right operand int list):

f:{(floor y%x;y mod x)}
vs[9; til 81]~f[9; til 81]

I don’t know why currently it is working only with 9…

perhaps it was needed for sudoku solver ;-)

cheers,
nml

looks like only that specific pair of arguments works–9 and til 81On Tue, May 20, 2008 at 2:42 PM, nml wrote:>> hi Yoel,>> afaik vs function should work as following (for left operant int,> right operand int list):>> f:{(floor y%x;y mod x)}> vs[9; til 81]~f[9; til 81]>> I don’t know why currently it is working only with 9…>> perhaps it was needed for sudoku solver ;-)>> cheers,> nml>> On May 20, 8:59 am, “Yoel Jacobsen” <yoel.jacob…> wrote:>> Hi nml,>>>> The reference on code.kx.com only does not mentions what is vs function when>> the LHS argument is a number. The only options are a character, 0b, 0x0 and>> `.>>>> What is its function with a number? It also seems to work only with 9 as an>> argument..>>>> Yoel>>>> On Tue, May 20, 2008 at 6:54 AM, Yoel Jacobsen <yoel.jacob…>>> wrote:>>>> > Yes it is. Thanks!>>>> > On Tue, May 20, 2008 at 2:43 AM, nml <nomorelo…> wrote:>>>> >> Hi,>>>> >> q version may be easier to read:>> >> p,:3 sv floor(p:9 vs til 81)%3>>>> >> Cheers,>> >> nml>>>> >> On May 18, 1:21 pm, felix <felix.lu…> wrote:>> >> > joel,>>>> >> > : and /: are vs and sv functions in q.>> >> > they have to many functionalities depending on left argument.>>>> >> > in this particular examaple, it expands the radices of 9 over this !81>> >> > vector.>> >> > this used to work on any shape of the y arg in k3.>> >> > in q works on specific arguments only.>>>> >> > the reverse 3/: is evaluating y in radices of x.>>>> >> > felix> >>– Aaron Daviesaaron.davies@gmail.com</felix.lu…></nomorelo…></yoel.jacob…></yoel.jacob…>

proof:q)where not"nyi"~/:(!).(::;{.[vs;(x 0;til x 1);::]}each)@:(til1000)cross til 10009 81On Tue, May 20, 2008 at 4:37 PM, Aaron Davies <aaron.davies> wrote:> looks like only that specific pair of arguments works–9 and til 81>> On Tue, May 20, 2008 at 2:42 PM, nml wrote:>>>> hi Yoel,>>>> afaik vs function should work as following (for left operant int,>> right operand int list):>>>> f:{(floor y%x;y mod x)}>> vs[9; til 81]~f[9; til 81]>>>> I don’t know why currently it is working only with 9…>>>> perhaps it was needed for sudoku solver ;-)>>>> cheers,>> nml>>>> On May 20, 8:59 am, “Yoel Jacobsen” <yoel.jacob…> wrote:>>> Hi nml,>>>>>> The reference on code.kx.com only does not mentions what is vs function when>>> the LHS argument is a number. The only options are a character, 0b, 0x0 and>>> `.>>>>>> What is its function with a number? It also seems to work only with 9 as an>>> argument..>>>>>> Yoel>>>>>> On Tue, May 20, 2008 at 6:54 AM, Yoel Jacobsen <yoel.jacob…>>>> wrote:>>>>>> > Yes it is. Thanks!>>>>>> > On Tue, May 20, 2008 at 2:43 AM, nml <nomorelo…> wrote:>>>>>> >> Hi,>>>>>> >> q version may be easier to read:>>> >> p,:3 sv floor(p:9 vs til 81)%3>>>>>> >> Cheers,>>> >> nml>>>>>> >> On May 18, 1:21 pm, felix <felix.lu…> wrote:>>> >> > joel,>>>>>> >> > : and /: are vs and sv functions in q.>>> >> > they have to many functionalities depending on left argument.>>>>>> >> > in this particular examaple, it expands the radices of 9 over this !81>>> >> > vector.>>> >> > this used to work on any shape of the y arg in k3.>>> >> > in q works on specific arguments only.>>>>>> >> > the reverse 3/: is evaluating y in radices of x.>>>>>> >> > felix>> >>>>>>>> –> Aaron Davies> aaron.davies@gmail.com>– Aaron Daviesaaron.davies@gmail.com</felix.lu…></nomorelo…></yoel.jacob…></yoel.jacob…></aaron.davies>

Quite restricted functionality… :-)

Hmm.. I wonder which part of q rely on an internal Sudoku  solver :-)

all the rest is a side-effect2008/5/21 Yoel Jacobsen <yoel.jacobsen>:> Hmm.. I wonder which part of q rely on an internal Sudoku solver :-)>> On Tue, May 20, 2008 at 11:57 PM, nml wrote:>>>> Quite restricted functionality… :-)>>>> On May 20, 10:52 pm, “Aaron Davies” <aaron.dav…> wrote:>> > proof:>> >>> > q)where not"nyi"~/:(!).(::;{.[vs;(x 0;til x 1);::]}each)@:(til>> > 1000)cross til 1000>> > 9 81>> >>> >>> >>> > On Tue, May 20, 2008 at 4:37 PM, Aaron Davies <aaron.dav…>>> > wrote:>> > > looks like only that specific pair of arguments works–9 and til 81>> >>> > > On Tue, May 20, 2008 at 2:42 PM, nml <nomorelo…> wrote:>> >>> > >> hi Yoel,>> >>> > >> afaik vs function should work as following (for left operant int,>> > >> right operand int list):>> >>> > >> f:{(floor y%x;y mod x)}>> > >> vs[9; til 81]~f[9; til 81]>> >>> > >> I don’t know why currently it is working only with 9…>> >>> > >> perhaps it was needed for sudoku solver ;-)>> >>> > >> cheers,>> > >> nml>> >>> > >> On May 20, 8:59 am, “Yoel Jacobsen” <yoel.jacob…> wrote:>> > >>> Hi nml,>> >>> > >>> The reference on code.kx.com only does not mentions what is vs>> > >>> function when>> > >>> the LHS argument is a number. The only options are a character, 0b,>> > >>> 0x0 and>> > >>> `.>> >>> > >>> What is its function with a number? It also seems to work only with>> > >>> 9 as an>> > >>> argument..>> >>> > >>> Yoel>> >>> > >>> On Tue, May 20, 2008 at 6:54 AM, Yoel Jacobsen>> > >>> <yoel.jacob…>>> > >>> wrote:>> >>> > >>> > Yes it is. Thanks!>> >>> > >>> > On Tue, May 20, 2008 at 2:43 AM, nml <nomorelo…>>> > >>> > wrote:>> >>> > >>> >> Hi,>> >>> > >>> >> q version may be easier to read:>> > >>> >> p,:3 sv floor(p:9 vs til 81)%3>> >>> > >>> >> Cheers,>> > >>> >> nml>> >>> > >>> >> On May 18, 1:21 pm, felix <felix.lu…> wrote:>> > >>> >> > joel,>> >>> > >>> >> > : and /: are vs and sv functions in q.>> > >>> >> > they have to many functionalities depending on left argument.>> >>> > >>> >> > in this particular examaple, it expands the radices of 9 over>> > >>> >> > this !81>> > >>> >> > vector.>> > >>> >> > this used to work on any shape of the y arg in k3.>> > >>> >> > in q works on specific arguments only.>> >>> > >>> >> > the reverse 3/: is evaluating y in radices of x.>> >>> > >>> >> > felix>> >>> > > –>> > > Aaron Davies>> > > aaron.dav...@gmail.com>> >>> > –>> > Aaron Davies>> > aaron.dav...@gmail.com>>>>> >></felix.lu…></nomorelo…></yoel.jacob…></yoel.jacob…></nomorelo…></aaron.dav…></aaron.dav…></yoel.jacobsen>

Was the original solution written in k, or in q?

I am not familiar at all with the issue,

but is it possible that it works in k, and not in q?

 

I tried to find the code, but the link to the example in code.kx.com has been disabled.

The original solution was in K3.

It works perfectly well in q (switching to k using \ ).

Yoel

Are you saying that when in q, you can switch to k?

If so, I wasn’t aware of that.

Where is that documented?

https://code.kx.com/trac/wiki/QforMortals2/commands_and_system_variables#Terminate

Read carefully ..

On Wed, May 21, 2008 at 9:18 PM, Tom Szczesny <tavmem@gmail.com> wrote:

Are you saying that when in q, you can switch to k?

If so, I wasn’t aware of that.

Where is that documented?

I love it.   That really is marvelous.   Thanks much!

However, after switching to k(in q 2.4), limitation of 9:!81 still
exists
(vs definition is vs:{x:y})

just a quick correction, that’s k4, not k3.On Wed, May 21, 2008 at 2:09 PM, Yoel Jacobsen <yoel.jacobsen> wrote:> The original solution was in K3.>> It works perfectly well in q (switching to k using \ ).>> Yoel>> On Wed, May 21, 2008 at 8:53 PM, Tom Szczesny wrote:>>>> Was the original solution written in k, or in q?>> I am not familiar at all with the issue,>> but is it possible that it works in k, and not in q?>>>> I tried to find the code, but the link to the example in code.kx.com has>> been disabled.>>>> On Wed, May 21, 2008 at 10:23 AM, simon garland <simon.garland>>> wrote:>>>>>> all the rest is a side-effect>>>>>> 2008/5/21 Yoel Jacobsen <yoel.jacobsen>:>>> > Hmm.. I wonder which part of q rely on an internal Sudoku solver :-)>>> >>>> > On Tue, May 20, 2008 at 11:57 PM, nml wrote:>>> >>>>> >> Quite restricted functionality… :-)>>> >>>>> >> On May 20, 10:52 pm, “Aaron Davies” <aaron.dav…> wrote:>>> >> > proof:>>> >> >>>> >> > q)where not"nyi"~/:(!).(::;{.[vs;(x 0;til x 1);::]}each)@:(til>>> >> > 1000)cross til 1000>>> >> > 9 81>>> >> >>>> >> >>>> >> >>>> >> > On Tue, May 20, 2008 at 4:37 PM, Aaron Davies>>> >> > <aaron.dav…>>>> >> > wrote:>>> >> > > looks like only that specific pair of arguments works–9 and til>>> >> > > 81>>> >> >>>> >> > > On Tue, May 20, 2008 at 2:42 PM, nml <nomorelo…>>>> >> > > wrote:>>> >> >>>> >> > >> hi Yoel,>>> >> >>>> >> > >> afaik vs function should work as following (for left operant int,>>> >> > >> right operand int list):>>> >> >>>> >> > >> f:{(floor y%x;y mod x)}>>> >> > >> vs[9; til 81]~f[9; til 81]>>> >> >>>> >> > >> I don’t know why currently it is working only with 9…>>> >> >>>> >> > >> perhaps it was needed for sudoku solver ;-)>>> >> >>>> >> > >> cheers,>>> >> > >> nml>>> >> >>>> >> > >> On May 20, 8:59 am, “Yoel Jacobsen” <yoel.jacob…>>>> >> > >> wrote:>>> >> > >>> Hi nml,>>> >> >>>> >> > >>> The reference on code.kx.com only does not mentions what is vs>>> >> > >>> function when>>> >> > >>> the LHS argument is a number. The only options are a character,>>> >> > >>> 0b,>>> >> > >>> 0x0 and>>> >> > >>> `.>>> >> >>>> >> > >>> What is its function with a number? It also seems to work only>>> >> > >>> with>>> >> > >>> 9 as an>>> >> > >>> argument..>>> >> >>>> >> > >>> Yoel>>> >> >>>> >> > >>> On Tue, May 20, 2008 at 6:54 AM, Yoel Jacobsen>>> >> > >>> <yoel.jacob…>>>> >> > >>> wrote:>>> >> >>>> >> > >>> > Yes it is. Thanks!>>> >> >>>> >> > >>> > On Tue, May 20, 2008 at 2:43 AM, nml <nomorelo…>>>> >> > >>> > wrote:>>> >> >>>> >> > >>> >> Hi,>>> >> >>>> >> > >>> >> q version may be easier to read:>>> >> > >>> >> p,:3 sv floor(p:9 vs til 81)%3>>> >> >>>> >> > >>> >> Cheers,>>> >> > >>> >> nml>>> >> >>>> >> > >>> >> On May 18, 1:21 pm, felix <felix.lu…> wrote:>>> >> > >>> >> > joel,>>> >> >>>> >> > >>> >> > : and /: are vs and sv functions in q.>>> >> > >>> >> > they have to many functionalities depending on left>>> >> > >>> >> > argument.>>> >> >>>> >> > >>> >> > in this particular examaple, it expands the radices of 9>>> >> > >>> >> > over>>> >> > >>> >> > this !81>>> >> > >>> >> > vector.>>> >> > >>> >> > this used to work on any shape of the y arg in k3.>>> >> > >>> >> > in q works on specific arguments only.>>> >> >>>> >> > >>> >> > the reverse 3/: is evaluating y in radices of x.>>> >> >>>> >> > >>> >> > felix>>> >> >>>> >> > > –>>> >> > > Aaron Davies>>> >> > > aaron.dav...@gmail.com>>> >> >>>> >> > –>>> >> > Aaron Davies>>> >> > aaron.dav...@gmail.com>>> >>>>> >>>> >>>> > >>>> >>>>>>>>>>>>>>>> >>– Aaron Daviesaaron.davies@gmail.com</felix.lu…></nomorelo…></yoel.jacob…></yoel.jacob…></nomorelo…></aaron.dav…></aaron.dav…></yoel.jacobsen></simon.garland></yoel.jacobsen>

u can also run single lines of k by using k)% qKDB+ 2.4 2008.04.18 Copyright (C) 1993-2008 Kx Systemsl64/ 4()core 15873MBq)sum 1 2 36q)k)+/1 2 36On Wed, May 21, 2008 at 2:33 PM, Tom Szczesny wrote:> I love it. That really is marvelous. Thanks much!>> On Wed, May 21, 2008 at 2:21 PM, Yoel Jacobsen <yoel.jacobsen>> wrote:>>>>>> https://code.kx.com/trac/wiki/QforMortals2/commands_and_system_variables#Terminate&gt;&gt;&gt;&gt; Read carefully ..>>>> On Wed, May 21, 2008 at 9:18 PM, Tom Szczesny wrote:>>>>>> Are you saying that when in q, you can switch to k?>>> If so, I wasn’t aware of that.>>> Where is that documented?>>>>>> On Wed, May 21, 2008 at 2:09 PM, Yoel Jacobsen <yoel.jacobsen>>>> wrote:>>>>>>>> The original solution was in K3.>>>>>>>> It works perfectly well in q (switching to k using \ ).>>>>>>>> Yoel>>>>>>>> On Wed, May 21, 2008 at 8:53 PM, Tom Szczesny wrote:>>>>>>>>>> Was the original solution written in k, or in q?>>>>> I am not familiar at all with the issue,>>>>> but is it possible that it works in k, and not in q?>>>>>>>>>> I tried to find the code, but the link to the example in code.kx.com>>>>> has been disabled.>>>>>>>>>> On Wed, May 21, 2008 at 10:23 AM, simon garland>>>>> <simon.garland> wrote:>>>>>>>>>>>> all the rest is a side-effect>>>>>>>>>>>> 2008/5/21 Yoel Jacobsen <yoel.jacobsen>:>>>>>> > Hmm.. I wonder which part of q rely on an internal Sudoku solver>>>>>> > :-)>>>>>> >>>>>>> > On Tue, May 20, 2008 at 11:57 PM, nml wrote:>>>>>> >>>>>>>> >> Quite restricted functionality… :-)>>>>>> >>>>>>>> >> On May 20, 10:52 pm, “Aaron Davies” <aaron.dav…> wrote:>>>>>> >> > proof:>>>>>> >> >>>>>>> >> > q)where not"nyi"~/:(!).(::;{.[vs;(x 0;til x 1);::]}each)@:(til>>>>>> >> > 1000)cross til 1000>>>>>> >> > 9 81>>>>>> >> >>>>>>> >> >>>>>>> >> >>>>>>> >> > On Tue, May 20, 2008 at 4:37 PM, Aaron Davies>>>>>> >> > <aaron.dav…>>>>>>> >> > wrote:>>>>>> >> > > looks like only that specific pair of arguments works–9 and>>>>>> >> > > til 81>>>>>> >> >>>>>>> >> > > On Tue, May 20, 2008 at 2:42 PM, nml <nomorelo…>>>>>>> >> > > wrote:>>>>>> >> >>>>>>> >> > >> hi Yoel,>>>>>> >> >>>>>>> >> > >> afaik vs function should work as following (for left operant>>>>>> >> > >> int,>>>>>> >> > >> right operand int list):>>>>>> >> >>>>>>> >> > >> f:{(floor y%x;y mod x)}>>>>>> >> > >> vs[9; til 81]~f[9; til 81]>>>>>> >> >>>>>>> >> > >> I don’t know why currently it is working only with 9…>>>>>> >> >>>>>>> >> > >> perhaps it was needed for sudoku solver ;-)>>>>>> >> >>>>>>> >> > >> cheers,>>>>>> >> > >> nml>>>>>> >> >>>>>>> >> > >> On May 20, 8:59 am, “Yoel Jacobsen” <yoel.jacob…>>>>>>> >> > >> wrote:>>>>>> >> > >>> Hi nml,>>>>>> >> >>>>>>> >> > >>> The reference on code.kx.com only does not mentions what is>>>>>> >> > >>> vs>>>>>> >> > >>> function when>>>>>> >> > >>> the LHS argument is a number. The only options are a>>>>>> >> > >>> character, 0b,>>>>>> >> > >>> 0x0 and>>>>>> >> > >>> `.>>>>>> >> >>>>>>> >> > >>> What is its function with a number? It also seems to work>>>>>> >> > >>> only with>>>>>> >> > >>> 9 as an>>>>>> >> > >>> argument..>>>>>> >> >>>>>>> >> > >>> Yoel>>>>>> >> >>>>>>> >> > >>> On Tue, May 20, 2008 at 6:54 AM, Yoel Jacobsen>>>>>> >> > >>> <yoel.jacob…>>>>>>> >> > >>> wrote:>>>>>> >> >>>>>>> >> > >>> > Yes it is. Thanks!>>>>>> >> >>>>>>> >> > >>> > On Tue, May 20, 2008 at 2:43 AM, nml>>>>>> >> > >>> > <nomorelo…>>>>>>> >> > >>> > wrote:>>>>>> >> >>>>>>> >> > >>> >> Hi,>>>>>> >> >>>>>>> >> > >>> >> q version may be easier to read:>>>>>> >> > >>> >> p,:3 sv floor(p:9 vs til 81)%3>>>>>> >> >>>>>>> >> > >>> >> Cheers,>>>>>> >> > >>> >> nml>>>>>> >> >>>>>>> >> > >>> >> On May 18, 1:21 pm, felix <felix.lu…> wrote:>>>>>> >> > >>> >> > joel,>>>>>> >> >>>>>>> >> > >>> >> > : and /: are vs and sv functions in q.>>>>>> >> > >>> >> > they have to many functionalities depending on left>>>>>> >> > >>> >> > argument.>>>>>> >> >>>>>>> >> > >>> >> > in this particular examaple, it expands the radices of 9>>>>>> >> > >>> >> > over>>>>>> >> > >>> >> > this !81>>>>>> >> > >>> >> > vector.>>>>>> >> > >>> >> > this used to work on any shape of the y arg in k3.>>>>>> >> > >>> >> > in q works on specific arguments only.>>>>>> >> >>>>>>> >> > >>> >> > the reverse 3/: is evaluating y in radices of x.>>>>>> >> >>>>>>> >> > >>> >> > felix>>>>>> >> >>>>>>> >> > > –>>>>>> >> > > Aaron Davies>>>>>> >> > > aaron.dav...@gmail.com>>>>>> >> >>>>>>> >> > –>>>>>> >> > Aaron Davies>>>>>> >> > aaron.dav...@gmail.com>>>>>> >>>>>>>> >>>>>>> >>>>>>> > >>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>– Aaron Daviesaaron.davies@gmail.com</felix.lu…></nomorelo…></yoel.jacob…></yoel.jacob…></nomorelo…></aaron.dav…></aaron.dav…></yoel.jacobsen></simon.garland></yoel.jacobsen></yoel.jacobsen>

Thank you.  That is very useful.