puzzle algorithms


  • 100 doors problem

    Puzzle: There are 100 doors in a long hallway. They are all closed. The first time you walk by each door, you open it. The second time around, you close every second door (since they are all opened). On the third pass you stop at every third door and ...

  • 99 bottles problem

    # 99 Bottles of Beer # ## Puzzle: ## You must print the lyric of the song as follows: ``` 99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, 98 bottles of beer on the wall. 98 bottles of beer on the wall, 98 ...

  • einstein puzzle

    The zebra puzzle is a well-known logic puzzle. Many versions of the puzzle exist, including a version published in Life International magazine on December 17, 1962. The March 25, 1963, issue of Life contained the solution and the names of several ...

  • 10 harshad number

    Puzzle: A Harshad Number, in a given number base, is an integer that is divisible by the sum of its digit when written in that base. Write a function that returns whether an integer is a Harshad Number or not (in base 10). Solution: Of the numbers ...

  • monty hall problem

    The Monty Hall problem is a brain teaser, in the form of a probability puzzle (Gruber, Krauss and others), loosely based on the American television game show Let's Make a Deal and named after its original host, Monty Hall. The problem was originally ...

  • n queens problem

    The eight queens puzzle is the problem of placing eight chess queens on an 88 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, column, or diagonal. The eight queens puzzle is an ...

  • sudoku

    A standard Sudoku puzzle contains 81 cells, in a 9 by 9 grid, and has 9 zones, each zone being the intersection of the first, middle, or last 3 rows, and the first, middle, or last 3 columns. Each cell may contain a number from one to nine; each number ...

  • symmetric difference

    In mathematics, the symmetric difference of two sets is the set of elements which are in either of the sets and not in their intersection. The symmetric difference of the sets A and B is commonly denoted byororFor example, the symmetric difference of ...