One of my colleagues recently introduced me to Project Euler. Project Euler is a great way for you to solve mathematical problems using your preferred language and then compare your solution with others. However, I noticed that most of the problems there were not practical for q. Many were designed to use loops which are frowned up on in q. This is why I am going to start posting challenges here that are q/kdb+ related.
Our first challenge is about partial sort.
A developer asked on q/kdb+ google groups page about how to partially sort a list. Let’s say I have a list
:
53 66 59 30 85 89 23 60 6 52 39
I want to get:
30 53 59 66 85 89 23 60 6 52 39
Note that it found the middle number (89
) and then sorted the list up to that point.
Post your solutions in the comments section.
Continue reading “Challenge#1 – Partial sort”