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
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "name",
"type": "promptString",
"description": "New problem name",
"default": "NEW_PROBLEM_X"
"default": "New-Prbolem-Name"
}
],
"tasks": [
Expand Down
32 changes: 32 additions & 0 deletions Problems/One-Two-Skip-A-Few/One-Two-Skip-A-Few.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, it } from "vitest";
import howManyMissing from "./solver";

describe("Returns the correct number of missing numbers", () => {
it("should return 4 for [1, 2, 3, 8, 9]", () => {
expect(howManyMissing([1, 2, 3, 8, 9])).toEqual(4);
});

it("should return 1 for [1, 3]", () => {
expect(howManyMissing([1, 3])).toEqual(1);
});

it("should return 2 for [7, 10, 11, 12]", () => {
expect(howManyMissing([7, 10, 11, 12])).toEqual(2);
});

it("should return 5 for [1, 3, 5, 7, 9, 11]", () => {
expect(howManyMissing([1, 3, 5, 7, 9, 11])).toEqual(5);
});

it("should return 0 for [5, 6, 7, 8]", () => {
expect(howManyMissing([5, 6, 7, 8])).toEqual(0);
});

it("should return 0 for []", () => {
expect(howManyMissing([])).toEqual(0);
});

it("should return 100 for [5, 6, 86, 87, 90, 97, 111]", () => {
expect(howManyMissing([5, 6, 86, 87, 90, 97, 111])).toEqual(100);
});
});
43 changes: 43 additions & 0 deletions Problems/One-Two-Skip-A-Few/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# One-Two-Skip-A-Few

You are given a sorted list `l` of length `n`, for example `[1, 3, 4, 5, 7]`.

Your task is to determine how many numbers are missing between `l[0]` and `l[n - 1]`.
In other words, count how many numbers would appear if you counted from `l[0]` up to `l[n - 1]`, but are not present in the list.

Example:

Input:
l = [1, 3, 4, 5, 7]

Numbers between 1 and 7 would be:
1, 2, 3, 4, 5, 6, 7

Missing numbers:
2, 6

Output:
2

## Documentation

### Solution Idea

This problem can be solved with a simple mathematical observation.

If `x` is the starting number (`l[0]`) and `y` is the final number (`l[n - 1]`), then there are always `y - x + 1` total numbers when counting from `x` to `y`.

Since the list already contains `n` of those numbers, the number of missing numbers is:

`(y - x + 1) - n`

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

(I don't need to explain that 🙃)

---

### Information's

This problem comes from the newsletter [Sloth Bytes](https://slothbytes.beehiiv.com).
[Post](https://slothbytes.beehiiv.com/p/ai-agents) from November 18, 2025.
4 changes: 4 additions & 0 deletions Problems/One-Two-Skip-A-Few/solver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default function howManyMissing(list: number[]): number {
if (list.length <= 0) return 0;
return list.at(-1)! - list.at(0)! - list.length + 1;
}
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: **20 problems**
Solved: **21 problems**

🟢 Easy: 14
🟢 Easy: 15
🟠 Medium: 5
🔴 Hard: 1

Expand All @@ -36,6 +36,7 @@ Solved: **20 problems**
| [Shortest Path Dijkstra](./Problems/Shortes-Path-Dijkstra/README.md) | 🟠 Medium |
| [Sleep Time](./Problems/Sleep-Time/README.md) | 🟢 Easy |
| [Reach Exit](./Problems/Reach-Exit/README.md) | 🟢 Easy |
| [One Two Skip a Few](./Problems/One-Two-Skip-A-Few/README.md) | 🟢 Easy |

<!-- PROBLEMS_END -->

Expand Down
66 changes: 33 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{
"name": "problem-solving",
"version": "CP-20",
"description": "This Package is all about solving coding problems",
"homepage": "https://github.com/Dennis-Bauer/Problem-Solving#readme",
"bugs": {
"url": "https://github.com/Dennis-Bauer/Problem-Solving/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Dennis-Bauer/Problem-Solving.git"
},
"license": "ISC",
"author": "Dennis Bauer",
"type": "commonjs",
"scripts": {
"test": "vitest run ./Problems",
"test:dev": "vitest ./Problems --reporter=verbose",
"test:file": "vitest",
"test:ci": "vitest --run --passWithNoTests --reporter=json > vitest-report.json",
"build": "tsc",
"normalize": "biome check --write --unsafe",
"prepare": "husky install"
},
"dependencies": {
"decimal.js": "^10.6.0",
"husky": "^9.1.7",
"typescript": "^5.9.2",
"vitest": "^3.2.4"
},
"devDependencies": {
"@biomejs/biome": "2.3.11",
"@types/node": "^24.3.0"
}
"name": "problem-solving",
"version": "CP-20",
"description": "This Package is all about solving coding problems",
"homepage": "https://github.com/Dennis-Bauer/Problem-Solving#readme",
"bugs": {
"url": "https://github.com/Dennis-Bauer/Problem-Solving/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Dennis-Bauer/Problem-Solving.git"
},
"license": "ISC",
"author": "Dennis Bauer",
"type": "commonjs",
"scripts": {
"test": "vitest run ./Problems",
"test:dev": "vitest ./Problems --reporter=verbose",
"test:file": "vitest",
"test:ci": "vitest --run --passWithNoTests --reporter=json > vitest-report.json",
"build": "tsc",
"normalize": "biome check --write --unsafe",
"prepare": "husky install"
},
"dependencies": {
"decimal.js": "^10.6.0",
"husky": "^9.1.7",
"typescript": "^5.9.2",
"vitest": "^3.2.4"
},
"devDependencies": {
"@biomejs/biome": "2.3.11",
"@types/node": "^24.3.0"
}
}