GithubHelp home page GithubHelp logo

andrearcaina / pyggle Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 2.36 MB

Pyggle is a boggle solver library written in Python, and compiled to Next.js!

License: MIT License

Python 90.35% JavaScript 0.77% CSS 0.26% TypeScript 8.63%
boggle-solver nextjs tailwindcss pypi-package easyocr opencv fastapi

pyggle's Introduction

logo

Pyggle

Find all possible words given a boggle board and words (or none!), with a visual representation on how the algorithm works on the web!

Web Demo: Coming Soon!

Tech Stack

TYPESCRIPT NEXT.JS TAILWINDCSS
The frontend is developed using TypeScript and the Next.js framework, with Tailwind CSS as the chosen CSS framework.

PYTHON FASTAPI OpenCV EasyOCR
The backend framework chosen for this project is FastAPI, a performant Python-based web framework. In FastAPI, I create API endpoints to communicate with the frontend (the client). These endpoints are designed to decipher the given boggle board from the client and return all possible combinations, coordinates, and score using Pyggle. The user can also send an image of a boggle board where I use OpenCV to preprocess the image and use EasyOCR to accurately retrieve the characters from the boggle board.

The words and coordinates are then sent to the client as a JSON payload for the frontend to render.

Package

PyPi: https://pypi.org/project/pyggle/

Installation

pip install pyggle

Usage

Input is case sensitive (for the board).

The input would consist of: an N x M board as a string with rows separated by spaces. Alternatively, you can pass in a list of lists where each element is the character on the board.

If words is not passed as an argument, it will utilize a text file that consists of 479k words.

If official is not given as a boolean argument, find all words regardless of length, and the letter 'Q' is not represented as 'Qu'. If official is passed as a boolean argument, then the algorithm follows the official rules of boggle. Pyggle will solve and:

  • find all words that have a length greater than 3.
  • The letter 'Q' is now represented as 'Qu'.
from pyggle import Boggle

board = "ea st"

boggle = Boggle(board)

boggle.print_result()

For more functions from pyggle, check:

Output

I don't know how "ae" or "aes" or "ast" is a word, but w/e :P

a: [(0, 1)]
ae: [(0, 1), (0, 0)]
aes: [(0, 1), (0, 0), (1, 0)]
aet: [(0, 1), (0, 0), (1, 1)]
as: [(0, 1), (1, 0)]
ase: [(0, 1), (1, 0), (0, 0)]
ast: [(0, 1), (1, 0), (1, 1)]
at: [(0, 1), (1, 1)]
ate: [(0, 1), (1, 1), (0, 0)]
ates: [(0, 1), (1, 1), (0, 0), (1, 0)]
e: [(0, 0)]
ea: [(0, 0), (0, 1)]
east: [(0, 0), (0, 1), (1, 0), (1, 1)]
eat: [(0, 0), (0, 1), (1, 1)]
eats: [(0, 0), (0, 1), (1, 1), (1, 0)]
es: [(0, 0), (1, 0)]
est: [(0, 0), (1, 0), (1, 1)]
et: [(0, 0), (1, 1)]
eta: [(0, 0), (1, 1), (0, 1)]
etas: [(0, 0), (1, 1), (0, 1), (1, 0)]
s: [(1, 0)]
sa: [(1, 0), (0, 1)]
sae: [(1, 0), (0, 1), (0, 0)]
sat: [(1, 0), (0, 1), (1, 1)]
sate: [(1, 0), (0, 1), (1, 1), (0, 0)]
se: [(1, 0), (0, 0)]
sea: [(1, 0), (0, 0), (0, 1)]
seat: [(1, 0), (0, 0), (0, 1), (1, 1)]
set: [(1, 0), (0, 0), (1, 1)]
seta: [(1, 0), (0, 0), (1, 1), (0, 1)]
st: [(1, 0), (1, 1)]
sta: [(1, 0), (1, 1), (0, 1)]
t: [(1, 1)]
ta: [(1, 1), (0, 1)]
tae: [(1, 1), (0, 1), (0, 0)]
tas: [(1, 1), (0, 1), (1, 0)]
te: [(1, 1), (0, 0)]
tea: [(1, 1), (0, 0), (0, 1)]
teas: [(1, 1), (0, 0), (0, 1), (1, 0)]
ts: [(1, 1), (1, 0)]

pyggle's People

Contributors

andrearcaina avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

pyggle's Issues

string input

Make it so a user can input a board with spaces like: "ae st".

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.