Skip to content

Day 250 #516

Closed
Closed

Description

@vaskoz

Good morning! Here's your coding interview problem for today.

This problem was asked by Google.

A cryptarithmetic puzzle is a mathematical game where the digits of some numbers are represented by letters. Each letter represents a unique digit.

For example, a puzzle of the form:

  SEND
+ MORE
--------
 MONEY

may have the solution:

{'S': 9, 'E': 5, 'N': 6, 'D': 7, 'M': 1, 'O', 0, 'R': 8, 'Y': 2}

Given a three-word puzzle like the one above, create an algorithm that finds a solution.

Activity

  1. self-assigned this
    on Apr 29, 2019
  2. vaskoz commented on May 4, 2019

    @vaskoz
    OwnerAuthor

    Multiple solutions are possible, but I made my solver deterministic.
    So for the example above:

      SEND
    + MORE
    --------
     MONEY
    

    My answer is:

      7531
    + 0825
    ---------
     08356
    

    It always returns this solution to that problem. The algorithm does a brute force search by assigning digits to the lexicographically smallest runes first.

    Solution is:

    {'S': 7, 'E': 5, 'N': 3, 'D': 1, 'M': 0, 'O', 8, 'R': 2, 'Y': 6}
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions