Hacker Newsnew | past | comments | ask | show | jobs | submit | rak1507's commentslogin

You won't get anything from vapourware salesmen.


It seemingly takes a long time to write good software too, co-dfns is infinity+1 years in progress...


There's a difference between one line and short/terse/elegant.

  {m:(x,x)#til x*x; r:til[x]-x div 2; 2(flip r rotate')/m} 
generates magic squares of odd size, and the method is much clearer. This isn't even golfed as the variables have been left.


Do you know which method is this? Euler's by any chance? And do you have an idea how one would prove that it creates a magic square? It's actually one of my inspirations for writing this, the relationship between the code that does something and the proof that the code actually does what it claims. I'd argue an LLM would find the proof helpful if it were asked to generalize an existing function in some way


Oh nice solution, thanks for sharing!


Why not? All that is really required is knowing 1/(1-x) = 1+x+x^2+... and a bit of algebraic manipulation.


And the idea of a formal power series. And integer compositions. And combinatorial enumeration (counting sets in different ways for a proof). And a bit of set theory (cardinality of sets).

There is a whole lot of background stuff here that elementary school students do not have. Way more than what you’ve stated.


You definitely don't need to know any of that background to be able to arrive at the answer. To fully understand everything maybe, but all it takes is:

a = x^1 + x^4 + x^7 + ... = x(1 + x^3 + x^6 + ...) = x/(1-x^3)

a + a^3 + a^5 + ... = a(1 + a^2 + a^4 + ...) = a/(1-a^2)

Substitute + simplify. I don't think this is beyond a (fairly smart) elementary school student.


The question doesn’t ask for an answer, it asks for a proof. You can’t just write a bunch of algebra and call it a day. You have to justify all of your arguments.


There aren't really any complicated arguments being made, so I don't think a proof would be that involved.


You obviously have not taught mathematics to high school students.


The problem is that this isn't a "hashmap" in any meaningful sense, because all the operations are O(n).


Hey, I know you.

> all the operations are O(n)

Not true, fortunately!

The cat-gets pattern for insertion is clearly just an O(1) append. Similar for the replicate-gets in the deletion.

Finding the deletion mask might be O(n) or O(log n), depending[0] on the size of your search space.

Key is effectively just a radix sort, which is indeed O(n) on the keys, but a trad hashmap doesn't get any better in this case.

[0]:https://help.dyalog.com/19.0/#Language/Defined%20Functions%2...


The append is the only thing that is O(1), finding the deletion mask is linear (≠ is linear, isn't it?) and the actual deletion is also linear (⌿ is also linear).

       ]runtime -repeat=1s 'v←k1 ⋄ v⌿⍨←v≠2'

 \* Benchmarking "v←k1 ⋄ v⌿⍨←v≠2", repeat=1s
 ┌──────────┬──────────────┐
 │          │(ms)          │
 ├──────────┼──────────────┤
 │CPU (avg):│0.008491847826│
 ├──────────┼──────────────┤
 │Elapsed:  │0.008466372283│
 └──────────┴──────────────┘
       ]runtime -repeat=1s 'v←k2 ⋄ v⌿⍨←v≠2'

 \* Benchmarking "v←k2 ⋄ v⌿⍨←v≠2", repeat=1s
 ┌──────────┬────────────┐
 │          │(ms)        │
 ├──────────┼────────────┤
 │CPU (avg):│0.8333333333│
 ├──────────┼────────────┤
 │Elapsed:  │0.83        │
 └──────────┴────────────┘


I had a peek at your github profile, and noticed "sqlutilpy", "Python module to efficiently query SQL databases and return numpy arrays". K is like if a language just did that by default.


You have been talking about array languages on HN for at least 6 years, and still refuse to believe that anyone can read them!

What do you have to gain from this stance, and why don't you believe people who tell you otherwise?


It's not a question of can they read them, it's are they readable. I obviously don't believe things just because people say them. Do you?


When it comes to subjective opinions, what other choice do you have? Your idea of doing studies is interesting but that's not even been done for most languages, yet claiming "python is unreadable" would clearly be laughable.

Either everyone who uses array languages does actually find them readable, or they're all persistently lying for... what reason? And forcing themselves to use something they don't find readable? Why would anyone do that! Especially considering a lot of array language users are hobbyists, who have chosen to use them, it's not like they're forced to.


Personally I think the best comparison would be Python+Pandas/polars+... or R+tidyverse+..., the key thing being there's less need for the "..." in a language with good table manipulation etc built in.


What do you mean by x^x^x^... = 2? Isn't the solution to that sqrt(2)?


f(x,n) = f(x,n-1) ^ x

f(x,1) = x

c_n is such that f(c_n,n) = 2

c = lim c_n


Do you mean f(x,n-1)^x or x^f(x,n-1)? With the first definition, c=1, the second, c=sqrt(2). I'm still not seeing the connection to omega.


What's so hard about Day 12? It's just

    +/'{x:".",x;H:(-1+;1+i-)@'+|\m*i:!#m:x=\:"#."
     R:(x=x)({[h;d;x;y;z](z#0),+\(((-z)_~"#"=x)&z_d>z)*(*y),(-z+1)_y-0^y h}. H)[x]/y
     (*|R)-R@*|0,&1_*+m}.''1({("?"/:5#,x;,/5#,y)}.')\@[;1;.:]'" "\:'0:`:i/12.txt


This is what programming languages looked like to me before I learned programming


I'm doing this year in K2 (after a long hiatus from K). Is there a K4/5 binary? ATW gave me a K2 binary, but I miss some of the K4 and later functionality):

https://github.com/jnordwick/aok2024


I don't know if there's a specific k4 binary but you can run k4 through the q binary.


Any idea how close that is to valid J code?


My limited understanding is that K and J are very different, despite both being in the same language family. I found K a lot easier to grasp when I was playing with both languages years ago.


Is this Q? or k?


It's k4, the underlying language behind Q. With slight modifications it also runs in ngn/k which is FOSS.

https://ngn.codeberg.page/k/#eJxVjsFugzAMhu95iiyWik1CIGPtIVG...


Looks like K to me!


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: