WEEKEND PROGRAMMING CHALLENGE ISSUE #2


Image

Problem:

If A[N] is array of N integers. Shuffle the elements of A in such way that the differences between each neighbour elements d[i] = A[i]-A[i+1] make row in ascending order.

For instance:

A[4] = { 10, 2, 7, 4 }

possible soluions are:

{  2, 7, 10, 4 } because  (2 – 7) < (7 – 10) < (10 – 4)

or:

{ 4, 10, 7, 2 } because (4 – 10) < (10 – 7) < (7 – 2)

The rules

You can code the solution in any language during the weekend and have to submit it to info@olimex.com latest on Sunday March 31th .

On Monday we will upload the solutions on GitHub and review https://github.com/OLIMEX/WPC .

You can play with your real name or with nick if you want to be anonymous, we will not disclosure your personal info if you do not want to.

8 Comments (+add yours?)

  1. Rene
    Mar 30, 2013 @ 12:27:17

    ? this is just bubble sort or any of its versions.. Isn’t there supposed to be a rule to make it as fast as possible or the code as short as possible?

    Rgds,

    Rene

    Reply

  2. ngalia
    Mar 30, 2013 @ 15:26:25

    Reblogged this on ngalia.

    Reply

  3. Kristian Josef Delos Reyes
    Mar 31, 2013 @ 07:46:22

    it is challenging if you are trying to see it as expandable…. more than 4 have anyone tried this? 10 18 7 45 20

    Reply

  4. Kristian Josef Delos Reyes
    Mar 31, 2013 @ 07:58:23

    How do I send my solution?

    Reply

  5. Iain Cunningham (@IainIsm)
    Apr 02, 2013 @ 00:28:10

    I wish I’d had time to enter this weekend – I’d like to think that I’d have used Dijkstra’s algorithm, but I’m not sure that I would have!

    Reply

  6. Trackback: Weekend Programming Challenge Issue #2 Late Entry | olimex

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: