Algorithms based on Game Theory

## Minimum number of integers required to fill the NxM grid

Given a grid of size (NxM) is to be filled with integers. Filling of cells in the grid should be done in the following manner:… Read More »

## A modified game of Nim

Given an array arr[] of integers, two players A and B are playing a game where A can remove any number of non-zero elements from… Read More »

## Find the winner by adding Pairwise difference of elements in the array until Possible

Given an array arr[] of positive distinct integers, two players A and B are playing a game. At each move, a player selects two numbers… Read More »

## Count the numbers that can be reduced to zero or less in a game

Given two integers X and Y and an array of N integers. Player A can decrease any element of the array by X and Player… Read More »

## Find probability that a player wins when probabilities of hitting the target are given

Given four integers p, q, r and s. Two players are playing a game where both the players are hitting a target and the first… Read More »

## Predict the winner of the game | Sprague-Grundy

Given a 4×4 binary matrix. Two players A and B are playing a game, at each step a player can select any rectangle with all… Read More »

## Find the winner of the game with N piles of boxes

Given N piles containing White(W) and Black(B) boxes only, two players A and B play a game. Player A may remove any number of boxes… Read More »

## Maximum and minimum isolated vertices in a graph

Given ‘n’ vertices and ‘m’ edges of a graph. Find the minimum number and maximum number of isolated vertices that are possible in the graph.… Read More »

## Coin game of two corners (Greedy Approach)

Consider a two player coin game where each player gets turn one by one. There is a row of even number of coins, and a… Read More »

## Josephus Problem | (Iterative Solution)

There are N Children are seated on N chairs arranged around a circle. The chairs are numbered from 1 to N. The game starts going… Read More »

## Find the winner in nim-game

You are given an array A[] of n-elements. There are two players Alice and Bob. A Player can choose any of element from array and… Read More »

## Game of Nim with removal of one stone allowed

In Game of Nim, two players take turns removing objects from heaps or the pile of stones. Suppose two players A and B are playing… Read More »

## Check if the game is valid or not

Three players P1, P2 and P3 are playing a game. But at a time only two players can play the game, so they decided, at… Read More »

## Variation in Nim Game

Prerequisites: Sprague Gruncy theorem Grundy Numbers Nim is a famous game in which two players take turns removing items from distinct piles. During each turn,… Read More »

## Game of replacing array elements

There are two players A and B who are interested in playing a game of numbers. In each move a player pick two distinct number,… Read More »