• Advertisement
Sign in to follow this  

Help with Contest problem

This topic is 3955 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heres the problem Calculate the number of table arrangement so that any two cows sitting next to each other dont differ in height by no more than K inches. so for: 4 10 2 16 6 10 There are 4 cows, with heights 2, 16, 6, and 10. Two cows whose heights differ by more than 10 do not want to sit next to each other. Can anyone just give me some hints, i am completely stuck

Share this post


Link to post
Share on other sites
Advertisement
What are you after, code or just some help on abstracting and solving the problem?

I'd say some kind of comparison needs to be made - if you've got an array of cows within your program, element[i] and element[i+1] cannot differ by >10.

Consequently, if difference between Cow A and Cow B <=10, they can sit in adjacent array indices. However, if you're trying to sort it into order i.e. cow with height 1 at position [0], cow with height 4 at [1], cow at height 7 at [2], cow with height 19 not at position [3] because of our difference of 10 rule... then that's another story. That, in my mind, could wind up being quite complicated.

Not sure if I should be helping, actually - is this a contest like you say, or is this homework? We're not supposed to help with homework. I don't know if it's forum policy, but it's frowned upon.

Share this post


Link to post
Share on other sites
I would help you in this contest but I already gave the answers to all of the questions to one of your competitors because I want him to win. Sorry.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement