From 1fb367215fecc9f045bb03ae8dfd6be08db70fb9 Mon Sep 17 00:00:00 2001 From: Dennis Bauer Date: Sat, 14 Mar 2026 13:34:22 +0100 Subject: [PATCH 1/3] MAIN_COMMIT Added a new Utility type: IntRange --- utilities/types/intRange.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 utilities/types/intRange.ts diff --git a/utilities/types/intRange.ts b/utilities/types/intRange.ts new file mode 100644 index 0000000..ed5b8df --- /dev/null +++ b/utilities/types/intRange.ts @@ -0,0 +1,9 @@ +// Source - https://stackoverflow.com/a/39495173 +// Posted by AlexG, modified by community. See post 'Timeline' for change history +// Retrieved 2026-03-14, License - CC BY-SA 4.0 + +type Enumerate = Acc["length"] extends N + ? Acc[number] + : Enumerate; + +export type IntRange = Exclude, Enumerate>; From 1622cb0e45c3af0d0144f88181d3f4ab63bc302c Mon Sep 17 00:00:00 2001 From: Dennis Bauer Date: Sat, 14 Mar 2026 13:39:09 +0100 Subject: [PATCH 2/3] Setup Problem --- Problems/Missing-Number/README.md | 27 +++++++++++++++++++ .../Missing-Number/missing-number.test.ts | 16 +++++++++++ Problems/Missing-Number/solver.ts | 6 +++++ 3 files changed, 49 insertions(+) create mode 100644 Problems/Missing-Number/README.md create mode 100644 Problems/Missing-Number/missing-number.test.ts create mode 100644 Problems/Missing-Number/solver.ts diff --git a/Problems/Missing-Number/README.md b/Problems/Missing-Number/README.md new file mode 100644 index 0000000..c070f1d --- /dev/null +++ b/Problems/Missing-Number/README.md @@ -0,0 +1,27 @@ +# Missing-Number + +Create a function that takes an array of numbers between 1 and 10 (excluding one number) and returns the missing number. + +## Infos which are maybe needed + +- The array of numbers will be unsorted (not in order). +- Only one number will be missing. + +## Documentation + +### Solution Idea + +The Idea to solve this problem + +--- + +### [Implementation](./solver.ts) + +The implementation for solving this problem + +--- + +### Information's + +This problem comes from the newsletter [Sloth Bytes](https://slothbytes.beehiiv.com). +[Post](https://slothbytes.beehiiv.com/p/jit-compliation) from February 11, 2026. diff --git a/Problems/Missing-Number/missing-number.test.ts b/Problems/Missing-Number/missing-number.test.ts new file mode 100644 index 0000000..5ba8605 --- /dev/null +++ b/Problems/Missing-Number/missing-number.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from "vitest"; +import missingNumber from "./solver"; + +describe("Finds the missing number", () => { + it("should return 5 for the first number-row", () => { + expect(missingNumber([1, 2, 3, 4, 6, 7, 8, 9, 10])).toEqual(5); + }); + + it("should return 10 for the second number-row", () => { + expect(missingNumber([7, 2, 3, 6, 5, 9, 1, 4, 8])).toEqual(10); + }); + + it("should return 7 for the third number-row", () => { + expect(missingNumber([10, 5, 1, 2, 4, 6, 8, 3, 9])).toEqual(7); + }); +}); diff --git a/Problems/Missing-Number/solver.ts b/Problems/Missing-Number/solver.ts new file mode 100644 index 0000000..26ffc6a --- /dev/null +++ b/Problems/Missing-Number/solver.ts @@ -0,0 +1,6 @@ +import type { FixedArray } from "../../utilities/types/fixedArray"; +import type { IntRange } from "../../utilities/types/intRange"; + +export default function missingNumber(array: FixedArray, 9>): number { + throw new Error("Solution not implemented yet!"); +} From 4f5ee65e5d639e36ebd05966d30e2f35e9088618 Mon Sep 17 00:00:00 2001 From: Dennis Bauer Date: Sat, 14 Mar 2026 13:47:17 +0100 Subject: [PATCH 3/3] Finished problem --- Problems/Missing-Number/README.md | 4 ++-- Problems/Missing-Number/solver.ts | 2 +- README.md | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Problems/Missing-Number/README.md b/Problems/Missing-Number/README.md index c070f1d..ec7efb9 100644 --- a/Problems/Missing-Number/README.md +++ b/Problems/Missing-Number/README.md @@ -11,13 +11,13 @@ Create a function that takes an array of numbers between 1 and 10 (excluding one ### Solution Idea -The Idea to solve this problem +Sum all numbers in the array together and subtract this number from 55 (The sum from 1 to 10). --- ### [Implementation](./solver.ts) -The implementation for solving this problem +Doing exactly this what the solution idea says. --- diff --git a/Problems/Missing-Number/solver.ts b/Problems/Missing-Number/solver.ts index 26ffc6a..26280f8 100644 --- a/Problems/Missing-Number/solver.ts +++ b/Problems/Missing-Number/solver.ts @@ -2,5 +2,5 @@ import type { FixedArray } from "../../utilities/types/fixedArray"; import type { IntRange } from "../../utilities/types/intRange"; export default function missingNumber(array: FixedArray, 9>): number { - throw new Error("Solution not implemented yet!"); + return 55 - array.reduce((preVal, val) => preVal + val, 0); } diff --git a/README.md b/README.md index 4386135..7d58c23 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ This repository is about solving coding-problems. It contains famous (or not tha ## Problems -Solved: **24 problems** +Solved: **25 problems** -🟢 Easy: 18 +🟢 Easy: 19 🟠 Medium: 5 🔴 Hard: 1 @@ -40,6 +40,7 @@ Solved: **24 problems** | [Day number of year](./Problems/Day-Number-Of-Year/README.md) | 🟢 Easy | | [Remove the last vowel](./Problems/Remove-The-Last-Vowel/README.md) | 🟢 Easy | | [Bingo Check](./Problems/Bingo-Check/README.md) | 🟢 Easy | +| [Missing Number](./Problems/Missing-Number/README.md) | 🟢 Easy |