Prázdny
Prázdny

Task 4 was revealed 17.10.2024 at 18:00 CET

Login required

*

 

 

Available from 17.10.2024 18:00 CET until 18.10.2024 17:59 CET - You can get 4 points

*

Missing numbers

 

In a distant land, cradled by the towering Tatra Mountains and flowing rivers, where the brave robber Janosik robbed the rich people and gave to the poor, there was a village where numbers held a sacred place in the natural order. The villagers believed that numbers must exist in perfect sequence, and any gaps could disrupt the balance of their world. To prevent chaos, the wise elder would call upon the townsfolk to find the missing numbers and restore harmony.

 

This tradition reflected the deep mathematical heritage of their homeland—a place known for its medieval towns, stunning castles, and rich folklore. Today, you’ve been chosen to uphold this custom, just as generations before you have done in this central European land. Can you restore balance and honor the legacy of this nation?

 

 

Task Definition

Let's have an array of integers. The goal is to find missing elements and the minimum number of insertions needed to make all elements of the array consecutive integers.

Example:

Given the array arr = [4, 2, 1], the missing integer to make the array consecutive is 3. Therefore, the number of insertions needed is 1 and missing element is 3. Create a method, that counts how many integers are missing and return them.

 

 

Input Description

Input file contains n space-separated integers arr[i]. Check Input example for detailed overview.

 

Output Description

Output contains number n, which is minimum number of insertions needed to make array consecutive, following with comma and space separated missing elements in ascending order. Check output example for detailed explanation.

 

Input example

4 3 6 8

 

Output example

2: 5, 7

 

 

 

Your task

Read input file and into the field with the answer, enter :

  • the resulting values
  • the country, which the story refers to
  • at the end paste the source code of your program.

Click here to download the Task 4 Input File

 

 

~~~~~~~~~~~~~~~

Answer

Slovakia (we accepted Poland as well)

 

202: 24, 42, 43, 54, 60, 70, 81, 89, 182, 193, 206, 281, 304, 305, 311, 344, 354, 380, 415, 445, 494, 500, 564, 651, 664, 665, 672, 691, 697, 722, 779, 783, 803, 818, 819, 827, 829, 838, 883, 918, 935, 949, 952, 957, 988, 992, 1008, 1024, 1041, 1145, 1147, 1151, 1166, 1167, 1172, 1177, 1184, 1190, 1191, 1194, 1198, 1225, 1228, 1256, 1274, 1277, 1294, 1320, 1328, 1337, 1344, 1351, 1353, 1396, 1397, 1417, 1439, 1457, 1464, 1495, 1507, 1542, 1559, 1578, 1585, 1615, 1647, 1662, 1673, 1719, 1737, 1772, 1793, 1817, 1830, 1837, 1870, 1932, 1962, 2028, 2039, 2047, 2049, 2052, 2055, 2057, 2087, 2121, 2127, 2151, 2266, 2268, 2278, 2282, 2289, 2298, 2308, 2317, 2348, 2350, 2368, 2404, 2413, 2415, 2468, 2484, 2514, 2522, 2523, 2527, 2530, 2532, 2542, 2596, 2617, 2635, 2639, 2648, 2651, 2682, 2713, 2738, 2743, 2748, 2780, 2784, 2792, 2806, 2868, 2895, 2903, 2917, 2941, 2961, 2979, 2990, 3042, 3097, 3114, 3130, 3147, 3173, 3179, 3198, 3209, 3218, 3271, 3282, 3310, 3363, 3371, 3386, 3423, 3462, 3485, 3493, 3495, 3525, 3557, 3566, 3571, 3572, 3578, 3587, 3598, 3636, 3639, 3645, 3646, 3659, 3667, 3688, 3693, 3703, 3709, 3727, 3803, 3817, 3850, 3861, 3907, 3980

 

     

Points

Correct answer

Country

Source Code

Round 1

1

1

1

Round 2

2

1

1

Round 3

3

1

1

Round 4

4

1

1

Round 5

5

1

1

                 

 

Bonus points 

Quick and correct answer

 

Round 1

5

4

3

2

1

       

Round 2

                 

Round 3

7

6

5

4

3

2

1

   

Round 4

8

7

6

5

4

3

2

1

 

Round 5

9

8

7

6

5

4

3

2

1