Giter Site home page Giter Site logo

12345678910's Introduction

HackerRank Challenge: Memory Game

Challenge Description

You are given a React application that implements a Memory Game. The game consists of a grid of colored blocks that need to be matched in pairs. Each block has a pair color, and the order of the blocks is randomized. The player can click on two blocks, and if they match in color, they are considered a pair. The game keeps track of the number of matches and tries. The goal is to match all the blocks in as few tries as possible. Unflipped blocks should be colored using slate.

Task

Your task is to complete and enhance the existing code to meet the following requirements:

  1. Ensure that the game logic is functioning correctly, allowing the player to select two blocks and determining if they match.

  2. Display a message when the player successfully matches all pairs with the following conditions:

    • If the player completes the game perfectly (minimum tries), display a message: "Congratulations, you have completed the game perfectly!"
    • If the player completes the game but with more tries, display a message: "Congratulations, you have completed the game!"
  3. Implement a "Reset" button that allows the player to restart the game at any time. The "Reset" button should be disabled when there are no moves to reset.

  4. Enhance the game to provide a clear display of the number of matches and tries to the player. The game should accurately keep track of the following:

    • The number of matched pairs.
    • The total number of tries made by the player.

Input

  • You will work with the provided React application and the blocks array containing block colors.

Output

  • Your solution should modify the existing application to meet the requirements specified above.

Sample Input

const blocks = [
  'red', 'yellow', 'green', 'indigo',
  'orange', 'red', 'yellow', 'green',
  'indigo', 'orange', 'cyan', 'pink',
  'stone', 'cyan', 'pink', 'stone'
]

Sample Output

Your modified application should allow users to play the Memory Game with the specified requirements.

Figure 1 : Complete Flow Unperfect Flow

Figure 2 : Perfect Flow Perfect Flow

Note:

12345678910's People

Contributors

greezyzilla 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.