Need help creating an algorithm via /r/learnprogramming

Need help creating an algorithm

Evening /r/learnprogramming

The reason for this is because I'm having a bit of trouble coming up with an algorithm i need in order to solve the problem. This problem i'm talking about is from the 2016/2017 ACM international collegiate programming contest.

Here is the prompt.

Here is my progrss.

As you can see in my code, although works for 70% of inputs, it's by no means the utmost ideal solution. Makeshift/spaghetti code to say the least. And for such reason, I call for your help. I am thinking about creating the algorithm around the for loop with maybe some iteration based matrices where i set all possible option into 1's and 0's and thus find the best matching accommodation. The only problem is that i don't even know where to start……..would this even work?

Please help. Any suggestions/comments would be greatly appreciated. Thank you in advance and good day. Cheers! 🙂

Submitted July 14, 2017 at 12:17AM by SpaceMonkeyClan
via reddit


Leave a Reply

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

You are commenting using your 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