Git Product home page Git Product logo

discord-bots's Introduction

๐Ÿ’ซ About Me

I'm an indie dev that codes mostly in Java :)

๐Ÿ’ป Neat Stuff I Use

Affinity Photo Apache Maven Blender Java Jellyfin Nginx Trello

๐Ÿ“Š GitHub Stats



discord-bots's People

Contributors

dependabot[bot] avatar jasonhorkles avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

discord-bots's Issues

Incorrect Wordle highlighting

This affects words with two letters in it. Only one E should be highlighted:
image
image

Here is the fix, but written in Python. The zip() function btw lets me have multiple variables in a for loop.
First, it tallies the number of letters in the answer, then as it checks the guess, it decreases the tally for letters the exact place (first) then any letters left that are misplaced (second)

class LetterType:
    WRONG = 'โฌ›'
    MISPLACED = '๐ŸŸจ'
    EXACT = '๐ŸŸฉ'


def highlight(guess, answer):
    highlights = [LetterType.WRONG for i in answer]

    # Tallying
    answer_tally = {}
    for letter in answer:
        if answer_tally.get(letter) is not None:
            continue
        answer_tally[letter] = answer.count(letter)

    print("Answer:", answer)
    print("Guess: ", guess)

    # Green pass
    for i, current_letter_guess, current_letter_answer in zip(range(len(answer)), guess, answer):
        if current_letter_guess != current_letter_answer:
            continue

        highlights[i] = LetterType.EXACT
        answer_tally[current_letter_guess] -= 1

    # Yellow pass
    for i, current_letter_guess, current_letter_highlight in zip(range(len(answer)), guess, highlights):
        if current_letter_highlight == LetterType.EXACT:
            continue
        if answer_tally.get(current_letter_guess) == 0 or answer_tally.get(current_letter_guess) is None:
            continue

        highlights[i] = LetterType.MISPLACED
        answer_tally[current_letter_guess] -= 1

    print(''.join(highlights))
    return highlights


highlight("speed", "abide") # Expected: โฌ›โฌ›๐ŸŸจโฌ›๐ŸŸจ
highlight("speed", "erase") # Expected: ๐ŸŸจโฌ›๐ŸŸจ๐ŸŸจโฌ›
highlight("speed", "steal") # Expected: ๐ŸŸฉโฌ›๐ŸŸฉโฌ›โฌ›
highlight("speed", "crepe") # Expected: โฌ›๐ŸŸจ๐ŸŸฉ๐ŸŸจโฌ›

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.