As of May 4 2007 the scripts will autodetect your timezone settings. Nothing here has to be changed, but there are a few things

Please follow this blog

Search this blog

Sunday, July 31, 2011

The K programming language

Question

The decimal number, $585 = 10010010012_2$ (binary), is palindromic in both bases. Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.

Problem 36  - Project Euler

Answer

+/&(&/{x~|x}'2 10_vs\:)'!_1e6

That is, in the K programming language. If Java is verbose then I would say that K is autistic. It has been estimated that there are not more than 1000 professional K-programmers. Most of them highly paid and employed in the high-end financial sector ( London, New York ).

Another example.

Question

The nth term of the sequence of triangle numbers is given by $t(n) = \frac{n (n+1) }{2}$, so the first ten triangle numbers are $1, 3, 6, 10, 15, 21, 28, 36, 45, 55$. By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word value. For example, the word value for SKY is $19 + 11 + 25 = 55 = t(10)$. If the word value is a triangle number then we shall call the word a triangle word. Using words.txt, a 16K text file containing nearly two-thousand common English words, how many are triangle words?

Problem 42  - Project Euler

Answer

+/((+/-64+6h$.:)'","\:*0:`words.txt)in{_.5*x*1+x}@!99

Again, in the K programming language. ( I used 4 lines in Mathematica, it would take 20+ lines in Java. )

3 comments:

  1. If you are interested in K, then you may also want to look up J and Q, being in the same family of APL descendants. A disclaimer: I don't program in any of these (something I hope to remedy at some point :)).

    ReplyDelete
  2. Is there any book on K programming, at all? I haven't seen any yet.

    ReplyDelete

Popular Posts

Welcome to The Bridge

Mathematics: is it the fabric of MEST?
This is my voyage
My continuous mission
To uncover hidden structures
To create new theorems and proofs
To boldly go where no man has gone before




(Raumpatrouille – Die phantastischen Abenteuer des Raumschiffes Orion, colloquially aka Raumpatrouille Orion was the first German science fiction television series. Its seven episodes were broadcast by ARD beginning September 17, 1966. The series has since acquired cult status in Germany. Broadcast six years before Star Trek first aired in West Germany (in 1972), it became a huge success.)