Sha256: 3421df2519c6d31d39397bfe4ac014c16cf93a094d913169671fdea9e9cf2d3e

Contents?: true

Size: 1.29 KB

Versions: 74

Compression:

Stored size: 1.29 KB

Contents

# Alphametics

Write a function to solve alphametics puzzles.

[Alphametics](https://en.wikipedia.org/wiki/Alphametics) is a puzzle where
letters in words are replaced with numbers.

For example `SEND + MORE = MONEY`:

```text
  S E N D
  M O R E +
-----------
M O N E Y
```

Replacing these with valid numbers gives:

```text
  9 5 6 7
  1 0 8 5 +
-----------
1 0 6 5 2
```

This is correct because every letter is replaced by a different number and the
words, translated into numbers, then make a valid sum.

Each letter must represent a different digit, and the leading digit of
a multi-digit number must not be zero.

Write a function to solve alphametics puzzles.

## Hints
- To parse the text, you could try to use the [Sprache](https://github.com/sprache/Sprache/blob/develop/README.md) library. You can also find a good tutorial [here](https://www.thomaslevesque.com/2017/02/23/easy-text-parsing-in-c-with-sprache/).
- You can solve this exercise with a brute force algorithm, but this will possibly have a poor runtime performance.
Try to find a more sophisticated solution. 
- Hint: You could try the column-wise addition algorithm that is usually taught in school.



## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.179 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.178 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.177 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.176 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.175 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.174 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.173 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.172 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.171 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.170 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.169 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.167 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.166 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.165 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.164 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.163 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.162 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.161 tracks/csharp/exercises/alphametics/README.md
trackler-2.2.1.160 tracks/csharp/exercises/alphametics/README.md