Skip to content

Commit

Permalink
Correct the mistakes of the character recognition software
Browse files Browse the repository at this point in the history
  • Loading branch information
PheRum committed May 15, 2024
1 parent e12e666 commit f79d349
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Correct the mistakes of the character recognition software

https://www.codewars.com/kata/577bd026df78c19bca0002c0

Character recognition software is widely used to digitise printed texts. Thus the texts can be edited, searched and stored on a computer.

When documents (especially pretty old ones written with a typewriter), are digitised character recognition softwares often make mistakes.

Your task is correct the errors in the digitised text. You only have to handle the following mistakes:

- `S` is misinterpreted as `5`
- `O` is misinterpreted as `0`
- `I` is misinterpreted as `1`

The test cases contain numbers only by mistake.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { correct } from "./index";

describe("Tests", () => {
it("correct", () => {
expect(correct("L0ND0N")).toBe("LONDON");
expect(correct("DUBL1N")).toBe("DUBLIN");
expect(correct("51NGAP0RE")).toBe("SINGAPORE");
expect(correct("BUDAPE5T")).toBe("BUDAPEST");
expect(correct("PAR15")).toBe("PARIS");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function correct(text: string): string {
return text.replace(/5/g, "S").replace(/0/g, "O").replace(/1/g, "I");
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

### Katas solved

`Total`: 26 \
`8_kyu`: 25 \
`Total`: 27 \
`8_kyu`: 26 \
`7_kyu`: 0 \
`6_kyu`: 1 \
`5_kyu`: 0 \
Expand Down

0 comments on commit f79d349

Please sign in to comment.