GithubHelp home page GithubHelp logo

js-boggle-challenge's Introduction

General Assembly Logo

Boggle Challenge

Test for words on a boggle board.

IMPORTANT: This challenge is an exercise in problem solving. It is crucial to read this entire document first before beginning anything. We suggest whiteboarding to make sure you understand the problem.

Next, solve boggle as simply as possible (don't be clever!). Then, solve bigBoggle and compare it to your boggle solution. You might notice patterns. Finish by make a single solution work for every kind of boggle presented here.

Prerequisites

Instructions

  1. Fork and clone this repository.
  2. Change into the new directory.
  3. Install dependencies.
  4. Create and checkout a new branch to work on.
  5. Fulfill the listed requirements.

Starter code is available in lib/challenge.js. A pull request is not required, but it is necessary if you want a code review.

You may wish to refer to FAQs related to forking, cloning.

Requirements

Map row/column coordinates onto an array index (i.e. represent a square grid using a simple array). Use this mapping to return (potential) words from letters in the grid.

Boggle is a word game played with letter-dice arrange in a 4X4 tray.

A tray is just an array of length 16 with each element a single letter string.

A list of coordinate pairs is an array with length <= 4 and each element is an array of length 2. The sub-arrays contain two integers >= 0 and <= 3.

Write a function - in lib/challenge.js - that takes a tray and a list of coordinate pairs and returns a string representing the concatenation of the letters at each of the coordinates.

See bin/challenge.js for an example invocation. Run it with node bin/challenge.js.

You should run grunt nag before diagnosing any bugs, since it finds some of the most common sources of errors. After grunt nag passes, you should run grunt test to run the included tests. Tests will tell you whether of not you've met these requirements.

Bonuses

Only try these after completing the main challenge.

Big Boggle challenge

Big Boggle uses a 5X5 tray.

Make the following change in spec/challenge.spec.js to enable tests for this bonus.

- xdescribe('Big Boggle', () => {
+ describe('Big Boggle', () => {

Super Big Boggle challenge

Super Big Boggle uses a 6X6 tray.

Make the following change in spec/challenge.spec.js to enable tests for this bonus.

- xdescribe('Super Big Boggle', () => {
+ describe('Super Big Boggle', () => {

Validate inputs

  • Ensure tray has the correct length
  • Ensure that coordinates fall within the tray
  • Disallow coordinate pairs that aren't in a line

Return the empty string if a validation fails

  1. All content is licensed under a CC­BY­NC­SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].

js-boggle-challenge's People

Contributors

bengitscode avatar danman01 avatar jrhorn424 avatar micfin avatar

Watchers

 avatar  avatar  avatar

js-boggle-challenge's Issues

Would a more verbose solution in addition to the current solutions add value to beginner developers?

The current solution uses array methods and functions ins and outs which are not covered yet when Boggle is presented. I recognize it is a challenge so it should push their boundaries and the solution is very elegant. I wonder if also having a more verbose solution would be a nice addition to the solution branch. I've also added comments to the solution, I find comments very useful especially for new developers. Comments can often answer questions that they might otherwise ask a consultant.

// function name: boggle4x4 
// parameters: an array as the tray parameter and an array as the coordPairs parameter
// returns: a string
const boggle4x4 = function(tray, coordPairs) {

   // define a variable as an empty array
   let letters = [];

   // define a variable as a number 
   let trayPosition = 0;

   // loop through the coordPairs so we can access each element in the array
   for (let i = 0; i < coordPairs.length; i++) {

        // access the values in the coordPair array to get the tray position 
        trayPosition = coordPairs[i][0] * 4 + coordPairs[i][1];

        // add the letter in the tray position to the letters array
        letters[i] = tray[trayPosition];
    }

   // return the letters array as a combined string 
   return letters.join("");
}

Solution for anyBoggle too difficult to read

this 1-line solution, although clever, is very difficult to read, especially for students in their 1st week

const anyBoggle = (rank, tray, coords) =>
  coords.map(c => tray[c[0] * rank + c[1]]).join('');

Could the README benefit from inline examples of how Boggle works?

The README is fantastic but cohort 016 has many developers with english as a second language (ESL). I think ESL developers and others would benefit from an inline code example of the results we want because it will help clarify what the Boggle game is. I also added a link to where they would find the code examples in the test files so that habit is established early.

Suggested update:

A tray is just an array of length 16 with each element a single letter string.
Example in tests
Become familiar with checking the tests for examples like the one below.

const tray = 'dibtloambcgrumps'.split('');

A list of coordinate pairs is an array with length <= 4 and each element is an array of length 2. The sub-arrays contain two integers >= 0 and <= 3.
Example in tests

const coordPairs = [ [0, 0], [1, 1], [2, 2], [3, 3] ];

Write a function - in lib/challenge.js - that takes a tray and a list of coordinate pairs and returns a string representing the concatenation of the letters at each of the coordinates.
Example in tests

boggle(tray, coordPairs) // "dogs"

We do have an example for them in the bin, as described in the README, that does a great job at explaining this, but we might benefit from the inline examples.

See bin/challenge.js for an example invocation. Run it with node bin/challenge.js.

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.