GithubHelp home page GithubHelp logo

mmstiver / challenge-256-intermediate Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 8 KB

Solution to a variation on the Hat Puzzle for a reddit daily programming challenge.

License: MIT License

C# 100.00%

challenge-256-intermediate's Introduction

Implementation of the 256th daily programmer challenge over at Reddit.

link : https://www.reddit.com/r/dailyprogrammer/comments/48l3u9/20160302_challenge_256_intermediate_guess_my_hat/

Bonus data (10,000 records) completes in ~8 seconds.

Description

You are the game master of the game "Guess my hat color".

The game goes as following:

You put a group of n people in one row, each facing the same direction
You assign a collored hat to each person of the group
Now you let each person guess the color of their own hat, starting with the last person in the row.

There are only 2 colors of hats and each person can only see the color of hats in front of them. The group wins from the gamemaster if they can win by making only 1 mistake.

The challenge today is to write the logic to make the guess.

The person guessing can only see the persons in front of them (and their hats) and can hear the guesses from the persons behind them. They can NEVER look behind them or look at their own hat. Formal Inputs & Outputs Input description

You get the list of hat colors starting with the person in the back and going to the front Input 1 - 10 hats

Black White Black Black White White Black White White White

Input 2 - 11 hats

Black Black White White Black Black White Black White White White

Input 3 - 10 hats

Black Black Black Black Black Black Black Black Black White

Output description

You have to show the guesses of the persons and whether they passed the challenge (they should if your logic is correct). Notes/Hints

Obviously if you return at random Black or White this won't work. The person units will have to work togheter to get a result with maximum 1 mistake.

There is no fixed ratio, neither do the participants know what the ratio is. An example for the layout

You have 4 people with lined up like this:

Black -> White -> White -> Black

The one in the back can see:

White -> White -> Black

The second one sees:

White -> Black

And so on... Bonus

Here you have a large set (10000 hats). Make sure your program can handle this. Finally

challenge-256-intermediate's People

Contributors

mmstiver avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.