Code Monkey home page Code Monkey logo

codewords_solver's Introduction

Codewords solver

A simple ruby-based allgorithm for solving codewords (AKA Cypher crosswords) - popular in many newspapers.

Usage

require "codewords_solver"

CodewordsSolver.solve! coded_words: grid, starting_letters: { 5 => "F", 7 => "L" }

or

require "codewords_solver"

solver = CodewordsSolver.new grid, { 5 => "F", 7 => "L" }
solver.solve!

where

grid = [
  [1, 13, 7, 11],
  [22, 5, 5, 13, 10, 17, 4, 15],
  [4, 13, 18, 3, 23],
  [16, 13, 7, 7, 13, 22, 26],
  [15, 10, 4, 12, 24, 25, 7, 17],
  [25, 13, 4, 22],
  [12, 24, 22, 9, 26, 23],
  [5, 13, 12, 26, 10, 17],
  [17, 26, 21, 14],
  [24, 12, 4, 23, 13, 12, 26, 15],
  [19, 4, 22, 8, 17, 10, 23],
  [4, 12, 13, 15, 17],
  [11, 13, 15, 10, 22, 9, 26, 23],
  [2, 9, 13, 19],
  [1, 22, 4, 20, 15, 19, 12, 10, 17],
  [19, 22, 11],
  [7, 12, 18, 17, 4],
  [22, 25, 21, 13, 22, 9, 15],
  [15, 23, 12, 24, 13, 26, 12],
  [7, 17, 18, 22],
  [5, 13, 16, 16, 7, 17],
  [23, 12, 4, 23, 12, 26],
  [13, 11, 7, 17],
  [24, 13, 6, 23, 9, 4, 17],
  [17, 11, 13, 23, 13, 22, 26],
  [12, 11, 13, 17, 9],
  [15, 22, 26],
  [22, 21, 17, 4, 15, 7, 17, 17, 19],
]

which is a machine-representation of a real-world grid that looks like this:

IMG_2891

Note that while a codewords puzzle is typically formed into a grid with intersecting words, you do not need to mark such intersections here. A simple array of each of the numbered words will suffice!

Please note

A good codewords solver requires a good word list, and this one is far from perfect. If it isn't solving a puzzle or it's making a mistake, it's quite likely that it's because there are words missing from the list!

codewords_solver's People

Contributors

johansenja 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.