Giter Club home page Giter Club logo

wordle's Introduction

Hi there ๐Ÿ‘‹

  • ๐Ÿ“ˆ I'm a student of finance, markets/trading, AI, and Python working at Standard
  • ๐Ÿ’ป I make AI applications (see Jeeves), trading bots, Python packages, and more
  • โš ๏ธ All my deployed bot and software repos are private. I typically only release retired and inactive source code.
  • ๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘ I'm always open to ideas and collaboration!

Some active private projects

stats languages

wordle's People

Contributors

preritdas avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

wordle's Issues

Wordle hint response logic

bug

Hello. This photo was taken when I actually played Wordle.
The answer at this time was "ULTRA".
In this case, the second letter A of "MAMMA" seems to be judged as gray.
Similarly, for example, when the answer is ROBIN and WORRY is entered, the fourth R seems to be a gray judgment.

I forked your project and tried to write a code like this.

so,I checked green and yellow in order and tried to remove the hit words.

class Wordle:
    """Main Wordle game taking arguments of the answer and whether to check against the dictionary."""

    def __init__(self, word: str, real_words: bool):
        self.word = word.upper()
        self.real_words = real_words

    def response(self, guess: str):
        response = []
        answer = [c for c in self.word]
        guess = [c for c in guess]

        # correct(green) check
        for pos, char in enumerate(guess):
            if answer[pos] == char:
                # append hint
                hint = f"*{guess[pos]}*   "
                response.append({'pos': pos, 'hint': hint})
                # remove char
                answer[pos] = ''
                guess[pos] = ''

        # present(yellow) check
        for pos, char in enumerate(guess):
            if not char:
                continue
            if char in answer:
                hint = char + "   "
                response.append({'pos': pos, 'hint': hint})
                # remove char
                guess[pos] = ''
                for _pos, _char in enumerate(answer):
                    if _char == char:
                        answer[_pos] = ''
                        break

        # remains all absent(gray)
        for pos, char in enumerate(guess):
            if not char:
                continue
            hint = guess[pos].lower() + "   "
            response.append({'pos': pos, 'hint': hint})

        # sort by pos
        response.sort(key=lambda x: x['pos'])

        return [r['hint'] for r in response]
...
import wordle

game = wordle.Wordle(word='WRYYY', real_words=False)
game.run()
>>>
Attempt 1 >>> yyaaa
Y   Y   a   a   a   
Attempt 2 >>> rrryy
r   *R*   r   *Y*   *Y*   
Attempt 3 >>> yyyaa
Y   Y   *Y*   a   a   
Attempt 4 >>> yyayy
Y   y   a   *Y*   *Y*   
Attempt 5 >>> wryyy
*W*   *R*   *Y*   *Y*   *Y*   
Congratulations, you passed the wordle in 5 tries.

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.