GithubHelp home page GithubHelp logo

xwords-rs's Introduction

xwords

xwords is a fast library that fills crossword puzzles. This repo also contains a lightweight CLI for invoking the library.

Caveat Emptor

This is foremost a hobbyist project for me to learn a bit about profiling and optimizing rust. I am more than happy to accept contributions or to consider feature requests, but please be aware that the future of this project is somewhat uncertain.

CLI

This command fills a grid that is stored in a local file using a default wordlist.

$ xwords --input grids/20201005_empty.txt

CFS*ANGELI*ORDU
AIA*DEEPAS*SEIN
SCLAVONIAN*MFAS
IKANTLETGO*ALLE
OLDY**ROE*ANOSE
*YOOHOOMRSBLOOM
***FUGUE*IRIDAL
FAA*LIS*ECO*SPY
IMPROV*ACOOK***
BILLIEJEANKING*
SEUSS*IAD**CEIL
**STTIC**ALKALI
CITI*CACOMISTLE
CORN*OMOLON*LIS
CLEE*NATURA*YST

This command runs in about 2 seconds on my machine.

Library

use xwords::{crossword::Crossword, fill_crossword_with_default_wordlist};

fn main() -> Result<(), String> {
    let empty_crossword = Crossword::new(String::from(
        "
    *    *     
    *    *     
         *     
   *   *   *   
**    *        
      *     ***
     *    *    
   *       *   
    *    *     
***     *      
        *    **
   *   *   *   
     *         
     *    *    
     *    *    
",
    ))?;
    let filled_crossword = fill_crossword_with_default_wordlist(&empty_crossword)?;
    println!("{}", filled_crossword);
    Ok(())
}

/*
ZETA*TWIT*VOWEL
ETAT*IANA*EVOKE
RINTINTIN*REVIE
OCT*TIE*TUI*ENR
**ATHA*TASTINGS
TOLEAN*ILIES***
ISIAC*TEAN*STEM
ZAT*ACHATES*HRA
AYES*SETE*TYEES
***TUTSI*URALIC
VENERATE*SEWA**
ORA*TRO*UES*TOA
WISHI*NETASSETS
ETHIC*EVIL*USTO
RUEDA*SWAL*OTSU
*/

On my machine, the above snippet runs in about 3 seconds.

Behind the scenes, this snippet loads an indexed wordlist, and iteratively fills the input with valid words.

xwords-rs's People

Contributors

super7ramp avatar szunami avatar

Watchers

 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.