GithubHelp home page GithubHelp logo

lab-node-projects-and-organization's Introduction

Wordle Word Solver

This lab requires you to create a new node project, import the data from words.json, and create some functionality to use the data.

What is wordle?

Word list provided by tabatkins on GitHub

Getting started

  1. Fork and clone this repository.
  2. Navigate to the cloned repository's directory on your command line.
  3. Turn this project into a Node.js project by running npm init -y.
  4. Open up the repository in VSCode.
  5. Create an index.js file.
  6. Import words.json into index.js and confirm that it has been imported into your file by logging the value.

Instructions

To complete this lab, you will need to complete the functions listed below.

Wordle is a simple guessing game where you must guess a five-letter word in 6 tries or less.

Every time you guess a word, you learn if you have found any letters that are correct and in the correct position or correct but in the wrong position.

The goal will be to build two functions that will return a list of possible words that match your guesses so far.

You can see an implementation of this functionality using the instructions from tabatkin's version

Start simple

Write the following functions:

  • allWords logs all the words.
  • firstTenWords logs the first ten words.
  • nextTenWords logs the next 10 words.
  • firstXWords logs from 0 to x words.
  • subsetOfWords logs from x to y words.
  • sortWords logs all the words, sorted alphabetically.

Begin building the wordle solver functions

One of the biggest challenges in learning to code is learning how to break down a complex set of logic into small testable functions.

The worlde solver requires two functions:

  • One that returns a list of words that has matching letters in any position
  • One that returns a list of words that has matching letters that also match the position

Let's start with some simpler versions:

Write the following functions

  • wordsWithQ returns all the words that contain the letter q
  • findWordsWithLetter takes an argument letter and returns all the words with that matching letter

Note: When creating this functionality, it's okay to use just a sample set of 3-10 words. This step can make troubleshooting a bit easier. Be sure to test for the following scenarios:

  • find a word with the matching letter
  • find a word with more than one of the matching letter
  • find a word with no matching letters

Upgrade your functionality

Instead of hard-coding the value for findWordsWithLetter, instead set it up so the user can input a letter from the terminal.

The following would test the letter P with the findWordsWithLetter function:

node index.js p

Bonus

  • Write a function lettersMatch that lets you input up to 5 letters in any order and returns the words that match the criteria (don't worry about solving for duplicate letters).
    • node index.js aeiou
  • Write a function letttersExactMatch that lets you input a five-character string. Put letters with the exact placement in their place, and put a placeholder like . or _ for unknown letters.
  • node index.js exactly a_ie_
  • Update the function lettersMatch to handle duplicate letters
  • Create a new function that can handle both inputs
    • One input for matched letters in the wrong position
    • The second input for matched letters in the correct position
    • node index.js al__a o

lab-node-projects-and-organization's People

Contributors

krafalski avatar yminasona 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.