d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Codility - Challenge Yourself
Add Reply New Topic New Poll
Member
Posts: 5,988
Joined: May 6 2006
Gold: 30.00
Feb 8 2014 12:44am
Just found out about this tonight - check it out, especially if you are looking to interview with employers

https://codility.com/
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Feb 8 2014 11:28pm
Problem it gave me was

Code
A country network consisting of N cities and N − 1 roads connecting them is given. Cities are labeled with distinct integers within the range [0..(N − 1)]. Roads connect cities in such a way that each distinct pair of cities is connected either by a direct road or through a path consisting of direct roads. There is exactly one way to reach any city from any other city.
Starting out from city K, you have to plan a series of daily trips. Each day you want to visit a previously unvisited city in such a way that, on a route to that city, you will also pass through a maximal number of other unvisited cities (which will then be considered to have been visited). We say that the destination city is our daily travel target.
In the case of a tie, you should choose the city with the minimal label. The trips cease when every city has been visited at least once.
For example, consider K = 2 and the following network consisting of seven cities and six roads:

You start in city 2. From here you make the following trips:
day 1 − from city 2 to city 0 (cities 1 and 0 become visited),
day 2 − from city 0 to city 6 (cities 4 and 6 become visited),
day 3 − from city 6 to city 3 (city 3 becomes visited),
day 4 − from city 3 to city 5 (city 5 becomes visited).
The goal is to find the sequence of travel targets. In the above example we have the following travel targets: (2, 0, 6, 3, 5).
Write a function:
class Solution { int[] solution(int K, int[] T); }
that, given a non-empty zero-indexed array T consisting of N integers describing a network of N cities and N − 1 roads, returns the sequence of travel targets.
Array T describes a network of cities as follows:
if T[P] = Q and P ≠ Q, then there is a direct road between cities P and Q.
For example, given the following array T consisting of seven elements (this array describes the network shown above) and K = 2:
T[0] = 1
T[1] = 2
T[2] = 3
T[3] = 3
T[4] = 2
T[5] = 1
T[6] = 4
the function should return a sequence [2, 0, 6, 3, 5], as explained above.
Assume that:
N is an integer within the range [1..90,000];
each element of array T is an integer within the range [0..(N−1)];
there is exactly one (possibly indirect) connection between any two distinct roads.
Complexity:
expected worst-case time complexity is O(N);
expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).
Elements of input arrays can be modified.



Which is awesome, because I love graph theory. According to the problem description the graph is a MST. Which means to solve the problem you just want to look at the leafs of the tree, and for each new "trip" choose the leaf whose route contains the most unvisited nodes. Do this until you have traveled to every leaf, and you would have effectively hit every node in the graph.
Member
Posts: 3,580
Joined: Aug 17 2013
Gold: 275.01
Feb 10 2014 03:53pm
"Our Customers: "
*Glances at the EA symbol*
Why would you tell people this! :rofl:

Otherwise seems nice, I'll be sure to check it out, thanks!
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Feb 10 2014 05:04pm
Quote (SCVonSteroids @ Feb 10 2014 03:53pm)
"Our Customers: "
*Glances at the EA symbol*
Why would you tell people this! :rofl:

Otherwise seems nice, I'll be sure to check it out, thanks!


so other businesses know the service is legit and that other professionals use it
that's the general idea
Member
Posts: 2
Joined: Apr 24 2014
Gold: 0.00
Apr 28 2014 10:31am
codility focus mostly on logical challenges like the one Minkomonster posted. that's cool, but doesn't tell you how well can your candidate code in a certain language, IMO.
there are few other services with specific code challenges which give a better indicator of a real-world programming skills.
eg. interviewstreet.com, which is subscription based, and http://testdome.com which has a per-test pricing model

This post was edited by jasonracer on Apr 28 2014 10:35am
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Apr 28 2014 10:41am
What's an example of a programming challenge/quiz/brain teaser which would reflect real world programming?
Member
Posts: 2
Joined: Apr 24 2014
Gold: 0.00
Apr 29 2014 05:40am
I think this is a good example:
[URL]http://testdome.com/dome/Tests/Senior-Csharp-Back-End-Programming-Test[/URL]

click on the Live coding question (C#). You get a sample code in which you have to fix the bugs.

I think that interview also has something like that, but I couldn't find an example. check out the Real-Time CodePair tab:
[URL] https://www.interviewstreet.com/recruit2/[/URL]

what do you say?


ps. I don't know how to insert links, you'll have to copy-paste, sorry :)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll