Академический Документы
Профессиональный Документы
Культура Документы
Badminton
Proposed by Mohd Suhaimi Ramly
Badminton
Task: (i) keep track of badminton scores and
(ii) determine the winner of the match.
Goal: test (simple) logic programming skills.
At the end, need to determine winner.
Keep track of games won?
Winner of last point is winner of the match!
Badminton - Pseudocode
points = ABAAABBB...
score_A = score_B = 0 // set scores to 0-0
for each point points:
if point = A then score_A++
if point = B then score_B++
if score_A = 21 or score_B = 21: // game is won
print score_A + - + score_B
score_A = score_B = 0 // reset scores to 0-0
print point // winner of last point is winner of the match
Honey
Proposed by Lim Yun Kai
Honey
Task: Collect maximum amount of honey
from N place using pot of size M in at most K
steps.
Solution: Greedy.
Honey - Solution
A better way is to collect as many full pot as possible while taking the
input.
if fullpot >= K:
else:
Bitcoin
Proposed by Quah Fu Yong
Bitcoin
Task: Given a grid of known size and a
number of points, compute the maximum
squared distance between the points in the
grid
Test precomputation skills
1
2
3
4
5
Bitcoin - Algorithm
High level description:
-
Bitcoin - Algorithm
-
Secret
Proposed by Quah Fu Yong
Secret
Task: Given two strings, find if it is possible
to rotate one of the string to obtain the other
string
Test dynamic programming skills
Trains
Proposed by Ng Jia Jen
Trains
Task: To find a path that requires the least
amount of cost from a certain point A to point
B
Graph problem
Solved by Dijkstra's shortest path algorithm
Cost
Coordinates
99
1,3
Coordinates
Cost
Coordinates
119
1,2
119
1,4
119
2,3
Coordinates
Cost
Coordinates
129
1,1
139
2,2
139
2,2
129
2,4
129
2,4
129
1,5
Coordinates
129
1,1
From (1,2):
139
2,2
From (2,3):
139
2,2
129
2,4
129
2,4
129
1,5
Cost
Coordinates
129
1,1
139
2,2
139
2,2
129
2,4
129
2,4
129
1,5
Cost
Coordinates
139
2,2
139
2,2
Cost
Coordinates
139
2,2
139
2,2
139
2,5
139
2,5
159
2,1
Cost
Coordinates
159
2,1
169
2,1
Coordinates
From (1,1):
159
2,1
From (2,2):
169
2,1
Coordinates