KX Community

Find answers, ask questions, and connect with our KX Community around the world.

Home Forums kdb+ Challenge 5 – Crack the Code

  • Challenge 5 – Crack the Code

    Posted by megan_mcp on March 21, 2023 at 12:00 am

    Hi all, Im back again with another challenge! This week I have hidden the function I created within the spoiler tag below – I would love to see what solutions you come up with and then compare it to my own. As always, any suggestions or feedback on how to improve my solution would be greatly appreciated. Can’t wait to see everyone’s answers! 

    You are given a list of numbers.

    The original numbers have been squared, multiplied by 3 then added 8 to give;

    371, 56, 20, 251, 1091, 35, 683, 683, 440.

    Your task is to create a function that takes each of the above numbers, works out the original number and maps it to the corresponding letter of the alphabet. E.g. 1 = a , 2 = b, 3 = c.

    Once all 9 letters have been outputted it will reveal a message.

    func1:{[number] 
             orig_num:(sqrt[(number-8)%3]); 
             index:("i"$orig_num)-1; :.Q.a[index];
    }

     

    megan_mcp replied 2 months ago 3 Members · 2 Replies
  • 2 Replies
  • SJT

    Member
    April 4, 2023 at 12:00 am

     

    dc: .Q.a -1+ “j”$ sqrt %[;3] -[;8] :: / decrypt dc

    371 56 20 251 1091 35 683 683 440

     

    A sequence of unaries is close to an ideal style in q. According to Arthur Whitney, Ken Iverson considered even infix notation as a sequence of unaries, e.g. 2*3+4 as (2*)(3+)4.

    Note how qs apply/index dualism allows us to compose a list in with the unary functions.

    Goes without saying that all the iteration is implicit

  • mkeenan

    Member
    March 19, 2024 at 11:00 am
    q)n:371 56 20 251 1091 35 683 683 440 
    
    q).Q.a -1+7h$sqrt(n-8)%3 
    "kdbiscool" 
    
    q)//I agree
    
    
    

Log in to reply.