From f79d349d96cb72ddab7274007ae3443e79af055b Mon Sep 17 00:00:00 2001 From: Valery Malyshev Date: Wed, 15 May 2024 12:45:07 +0300 Subject: [PATCH] Correct the mistakes of the character recognition software --- .../README.md | 15 +++++++++++++++ .../index.test.ts | 11 +++++++++++ .../index.ts | 3 +++ README.md | 4 ++-- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 8_kyu/Correct the mistakes of the character recognition software/README.md create mode 100644 8_kyu/Correct the mistakes of the character recognition software/index.test.ts create mode 100644 8_kyu/Correct the mistakes of the character recognition software/index.ts diff --git a/8_kyu/Correct the mistakes of the character recognition software/README.md b/8_kyu/Correct the mistakes of the character recognition software/README.md new file mode 100644 index 0000000..bcff34a --- /dev/null +++ b/8_kyu/Correct the mistakes of the character recognition software/README.md @@ -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. diff --git a/8_kyu/Correct the mistakes of the character recognition software/index.test.ts b/8_kyu/Correct the mistakes of the character recognition software/index.test.ts new file mode 100644 index 0000000..12865ae --- /dev/null +++ b/8_kyu/Correct the mistakes of the character recognition software/index.test.ts @@ -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"); + }); +}); diff --git a/8_kyu/Correct the mistakes of the character recognition software/index.ts b/8_kyu/Correct the mistakes of the character recognition software/index.ts new file mode 100644 index 0000000..5131edb --- /dev/null +++ b/8_kyu/Correct the mistakes of the character recognition software/index.ts @@ -0,0 +1,3 @@ +export function correct(text: string): string { + return text.replace(/5/g, "S").replace(/0/g, "O").replace(/1/g, "I"); +} diff --git a/README.md b/README.md index acc6688..b0debda 100644 --- a/README.md +++ b/README.md @@ -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 \