Posted on

WEEKEND PROGRAMMING CHALLENGE ISSUE #2

olimex

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.

View original post

Advertisements

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