title-img


Poker Nim

Poker Nim is another -player game that's a simple variation on a Nim game. The rules of the games are as follows: The game starts with piles of chips indexed from to . Each pile (where ) has chips. The players move in alternating turns. During each move, the current player must perform either of the following actions: Remove one or more chips from a single pile. Add one or more chips to a single pile. At least chip must be added or removed during each turn. To ensure that the ga

View Solution →

Alice and Bob's Silly Game

Alice and Bob invented the following silly game: The game starts with an integer, , that's used to build a of distinct integers in the inclusive range from to (i.e., ). Alice always plays first, and the two players move in alternating turns. During each move, the current player chooses a prime number, , from . The player then removes and all of its multiples from . The first player to be unable to make a move loses the game. Alice and Bob play games. Given the value of for each gam

View Solution →

Tower Breakers, Revisited!

cTwo players (numbered and ) are playing a game of Tower Breakers! The rules of the game are as follows: Player always moves first, and both players always move optimally. Initially there are towers of various heights. The players move in alternating turns. In each turn, a player can choose a tower of height and reduce its height to , where and evenly divides . If the current player is unable to make any move, they lose the game. Given the value of and the respective height values

View Solution →

Frog in Maze

Alef the Frog is in an nxm two-dimensional maze represented as a table. The maze has the following characteristics: Each cell can be free or can contain an obstacle, an exit, or a mine. Any two cells in the table considered adjacent if they share a side. The maze is surrounded by a solid wall made of obstacles. Some pairs of free cells are connected by a bidirectional tunnel. When Alef is in any cell, he can randomly and with equal probability choose to move into one of the adjacent ce

View Solution →

Roads and Libraries

Determine the minimum cost to provide library access to all citizens of HackerLand. There are n cities numbered from 1 to n. Currently there are no libraries and the cities are not connected. Bidirectional roads may be built between any city pair listed in cities. A citizen has access to a library if: 1. Their city contains a library. 2. They can travel by road from their city to a city containing a library. unction Description Complete the function roadsAndLibraries in the editor be

View Solution →