Task 1 was revealed 27.10.2025 at 18:00 CET
Login required
Task: Trick or treat!
On a windy Halloween night, a little boy named Domi set off with a red bucket in hand, excited to collect chocolates.
Before he left, his parents gave him a few rules.
“You can collect as much candy as you like,” said his mom, “but later, you may only eat two pieces.
The rest will be saved for later.”
“And,” added his dad with a mischievous smile, “I'll be the one to decide just how heavy those two pieces can be.”
Task:
Domi has a bucket of chocolates, each with an associated weight, and he wants to select two of them to achieve the allowed weight.
Given a list of integers where each number represents the weight of a chocolate and an integer representing the target weight, you must find the index of the first two chocolates that add up to exactly the target weight.
Example 1
Input
[4, 5, 6, 2]
8
Output
2, 3
Example 2
(if no combination is found)
Input
[1, 2, 3, 4]
9
Output
null
Example 3
(In the case that there is more than one possible combination, select the combination whose second chocolate appears first in the list.)
Input
[1, 2, 3, 4]
5
Output
1, 2
(it could also be 0, 3 but there is a combination earlier)
Your task:
Read input file and into the field with the answer, enter :
- The resulting values on separated rows
- At the end paste the source code of your program.
Input file
Click HERE to download the input file.
Answer
Click HERE to download the answer.
| Points for | Correct answer | Source Code |
| Round 1 | 1 | 1 |
| Bonus points for | Quick and correct answer | ||||
| Round 1 | 5 | 4 | 3 | 2 | 1 |
Correct answer:
For each correctly solved case - 0.1 point.
For all correct answers bonus - 0.1 point