Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Problems/Missing-Number/README.md
Original file line number Diff line number Diff line change
@@ -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

Sum all numbers in the array together and subtract this number from 55 (The sum from 1 to 10).

---

### [Implementation](./solver.ts)

Doing exactly this what the solution idea says.

---

### 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.
16 changes: 16 additions & 0 deletions Problems/Missing-Number/missing-number.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
6 changes: 6 additions & 0 deletions Problems/Missing-Number/solver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { FixedArray } from "../../utilities/types/fixedArray";
import type { IntRange } from "../../utilities/types/intRange";

export default function missingNumber(array: FixedArray<IntRange<1, 11>, 9>): number {
return 55 - array.reduce((preVal, val) => preVal + val, 0);
}
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 |

<!-- PROBLEMS_END -->

Expand Down
9 changes: 9 additions & 0 deletions utilities/types/intRange.ts
Original file line number Diff line number Diff line change
@@ -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<N extends number, Acc extends number[] = []> = Acc["length"] extends N
? Acc[number]
: Enumerate<N, [...Acc, Acc["length"]]>;

export type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
Loading