Programming Challenge: Two Wizards algorithm challenge

Soptik
Tue, 14 Aug 2018 20:47:36 +0000

I'm running out of ideas, if you have any, please make your own programming challenge.

This challenge is about designing algorithm to solve this problem.

Let's have game field of size x, y (like in chess). There are two wizards, that are standing at [ 0, 0 ] and are teleporting themselves using spells. The goal is to not be the one who teleports them outside of the map. Each spell teleports wizard by at least +1 tile. Given map size and collection of spells, who wins (they do not make any mistakes)?

Here are few examples:

Example 1

x:4,y:5

Spells: { 0, 2 }

Output: false

Description: Wizard A starts, teleporting both of them to 0, 2. Wizard B teleports them to 0, 4. Wizard A has to teleport them to 0,6, which overflows from the map, so he loses the game. Because starting wizard (wizard A) loses, output is false.

Example 2

x:4,y:4

Spells: { 1,1 }

Output: true

Example 3

x:4,y:5

Spells: { 1,1 },{ 3,2 },{ 1,4 },{ 0,2 },{ 6,5 },{ 3,1 }

Output: true

Example 4

x:400,y:400

Spells: {9,2},{15,1},{1,4},{7,20},{3,100},{6,4},{9,0},{7,0},{8,3},{8,44}

Ouput: true

Good luck! I'll comment here my solution in about a day.

Note: This challenge comes from fiks, programming competition by Czech college ČVUT (CTU).

Comments URL: https://tildes.net/~comp/4ya/programming_challenge_two_wizards_algorithm_challenge

Votes: 15

Comments: 24