Help with Contest problem

Started by
2 comments, last by thedustbustr 17 years ago
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
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 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.
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.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
if runtime efficiency isn't a problem, build a search tree and search it.

This topic is closed to new replies.

Advertisement