Programming Challenge #1

Posts 110 of 10 · Page 1 of 1
Programming Challenge #1
Please note that these challenges are not self-made, please don't cheat by searching for it on google and getting a solution from elsewhere.

World Cup is going on! One of the most fascinating parts of it is the group stage that has recently ended. A lot of great teams face each other to reach the playoff stage. In the group stage, each pair of teams plays exactly one game and each team receives 3 points for a win, 1 point for a draw and 0 points for a loss.
You fell asleep. What a shame. While you were sleeping, your team has played a lot of games! Now you know how many matches your team has played, how many goals it has scored and how many has missed. Now you need to find out the maximum amount of points your team can have.

Please keep the meat of your solution inside one function with the following definition:
int maxPoints(int matches, int goalsFor, int goalsAgainst)

Examples you can test your code against are below. Please provide these inside your main function as maxPoints(matches,goalsFor,goalsAgainst) == solution. I will test your code with several solutions that are not listed here to ensure it functions according to the specifications.

matches goalsFor goalsAgainst Expected Output
2 1 2 3
2 3 2 4
3 3 5 6
2 3 3 3
1 2 4 0
2 1 4 3
1 4 1 3
1 5 5 1
2 2 2 3
3 2 1 6

Please follow these steps when submitting solutions:
Copy or create your solution over at https://www.ideone.com/.
Make sure it's set to secret! Else your solutions can show up to everyone.

Next, copy the URL you get from here over to https://***********/url/make, set a password of your chosing and reply to this topic with ONLY the short URL, and then send me a private message with the password to your solution.
https://***********/3svz - same password as before
I've found a nicer and even simpler solution for this problem after thinking about it again
You will see what I mean ;P
Quote Originally Posted by Zaczero View Post
https://***********/3svz - same password as before
I've found a nicer and even simpler solution for this problem after thinking about it again
You will see what I mean ;P
Congratulations! Solution passes all tests! I'll add your name to the leaderboards.


Quote Originally Posted by senfgas View Post
https://***********/3sxt

EDIT: I can't send PM's, can I send the password via the IM chat?
Via IM is fine! Looking forward to seeing your solution.
@senfgas your solution passed all the tests, added you to the list!
is this still ongoing?
i just rushed mine in java so its not very clean not sure how you would make it look cleaner though.

https://***********/5316

EDIT: sent you PM and woops i might not even need the OR check, would probably work without the second check at line 18
Thanks for your submission! I ran it against the test scenarios and it seems to pass them!
yay whens the second challenge
Posts 110 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?