22 Flags Game Theory Puzzle In C#

22 Flags Game Theory Puzzle In C#

22 Flags Game Theory Puzzle In C#. In this blog, you will learn how to create an unbeaten flag removal program with C#.


There is a classic game theory puzzle named “22 Flags Game” (the total flags and winning condition might vary from case to case). Two contestants are trying to move 1-3 flags from the 22 flags in turn, and whoever removes the last flag will be consider as a loser.

Let list down the rule and try to think deductively to come out with a winning strategy. In other words, each player has to make sure his/her opponent is being left with the last flag.

What is the best strategy to win this game?

  1. Game start with 22 flags
  2. Each player have and can only remove 1 to 3 flags per turn
  3. Each player remove the flag alternately by turn
  4. Whoever removes the last flag will lose


Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

CSharp Fibonacci Series - Write A Fibonacci Program

In this Video you will learn how to write a CSharp Fibonacci Series Programm. Learn how to use the Fibonacci Sequence in C#. Write a little C# Program to get Fibonacci Numbers. This Fibonacci Series is seen in Nature quite often.

CSharp Interview 50 Question and Answers

This video is a compilation of my 5 successful videos - 50 C# Interview Questions and Answers and should be seen as interview preparation.

Introducing C# 9: Improved pattern matching

Pattern matching has been introduced in C# 6 and has well evolved since. The latest improvement was pretty interesting on C# 8 which has been released last year. If you missed pattern matching improvements on C# 8 , here is a nice article from Miguel Bernard (@MiguelBernard88): https://blog.miguelbernard.com/pattern-matching-in-csharp/. If you have missed all new features in C# 8, you can read also his great serie here: https://blog.miguelbernard.com/csharp-8-0-new-features/. In this article I will show you all the great new features of pattern matching.

Introducing C# 9: Records

C# 9 Introduces a new keyword: record keyword. record keyword makes an object immutable and behave like a value type. data keyword replaces the init keyword for each property if you want the whole object (all properties) to be immutable.

Introducing C# 9: Init only properties

.NET 5 brings a new version of the C# language: C# 9. In this article we will discuss on a new feature: Init only properties. C# 9 Introduces init accessor (variant of set accessor) that allows properties to be assigned once during object initialization.