Giter VIP home page Giter VIP logo

periodic-spelling's Introduction

Spelling English Words with Elemental Symbols

An algorithm to spell an input English word using chemical symbols so that leftover letters are minimized. The optimal solutions with that uses the fewest chemical symbols is chosen.

For instance, "eras" would be spelled as Er As rather than e Ra s because the first spelling has 0 letters not contained in the elemental symbols while the second has 2 leftover letters.

Additionally, "rhinos" would be spelled as Rh In Os rather than Rh I No S because, while both are optimal, the first spelling uses 3 symbols and the second uses 4.

Dynamic Programming Solution

The data structure is a table of optimal solutions. We use this so we do not resolve overlapping subproblems.

     END INDEX
  0 1 2 ... k-1

L 1 X X X X E 2 X X X N G | T H k X

Each entry stores the number of characters in the corresponding subsequence that are covered by the optimal periodic spelling. In the first and second rows, we check if each subsequence matches any elemental symbol. From the second row onward, we also determine the optimal periodic spelling by splitting each subsequence into two subproblems (at each character) and summing the stored optimal solutions to those subproblems.

Time Complexity

Each of the i entries in row i must be filled. For a subsequence in row i, we partition the subsequence into two strings of positive length. There are i-1 ways to do this.

The running time does not vary based on differences in input of the same size.

To Do

  • Improve README.md
  • Generate optimal covering, not just length of optimal covering
  • Apply this method to compression

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.