From ef9900e53907ed86ea2f1b7057bd43a520249f8c Mon Sep 17 00:00:00 2001 From: Dennis Bauer Date: Sat, 14 Mar 2026 13:55:47 +0100 Subject: [PATCH 1/3] Setup Problem --- Problems/Seven-Boom/README.md | 26 ++++++++++++++++++++++++++ Problems/Seven-Boom/seven-boom.test.ts | 20 ++++++++++++++++++++ Problems/Seven-Boom/solver.ts | 3 +++ 3 files changed, 49 insertions(+) create mode 100644 Problems/Seven-Boom/README.md create mode 100644 Problems/Seven-Boom/seven-boom.test.ts create mode 100644 Problems/Seven-Boom/solver.ts diff --git a/Problems/Seven-Boom/README.md b/Problems/Seven-Boom/README.md new file mode 100644 index 0000000..a8da127 --- /dev/null +++ b/Problems/Seven-Boom/README.md @@ -0,0 +1,26 @@ +# Seven-Boom + +Create a function that takes an array of numbers and for every 7 found, add one "Boom!" to your result. If no 7 is found anywhere, return "there is no 7 in the array". + +## Infos which are maybe needed + +If e.g there is a `77` in the array, the count of 7's needs to increase by two. + +## 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/how-does-google-maps-find-the-fastest-route) from February 25, 2026. diff --git a/Problems/Seven-Boom/seven-boom.test.ts b/Problems/Seven-Boom/seven-boom.test.ts new file mode 100644 index 0000000..654adf2 --- /dev/null +++ b/Problems/Seven-Boom/seven-boom.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, it } from "vitest"; +import sevenBoom from "./solver"; + +describe("Determines the correct count of sevens in the array", () => { + it("should return one 'Boom!' for the first array", () => { + expect(sevenBoom([1, 2, 3, 4, 5, 6, 7])).toEqual("Boom!"); + }); + + it("should return 'there is no 7 in the array' for the second array", () => { + expect(sevenBoom([8, 6, 33, 100])).toEqual("there is not 7 in the array"); + }); + + it("should return one 'Boom' for the third array", () => { + expect(sevenBoom([2, 55, 60, 97, 86])).toEqual("Boom!"); + }); + + it("should return three 'Boom' for the fourth array", () => { + expect(sevenBoom([7, 77, 100])).toEqual("Boom! Boom! Boom!"); + }); +}); diff --git a/Problems/Seven-Boom/solver.ts b/Problems/Seven-Boom/solver.ts new file mode 100644 index 0000000..46be114 --- /dev/null +++ b/Problems/Seven-Boom/solver.ts @@ -0,0 +1,3 @@ +export default function sevenBoom(array: number[]): string { + throw new Error("Solution yet not implemented!"); +} From b0753843077ec2c1d5bbc15ce3fb4c59c6b46311 Mon Sep 17 00:00:00 2001 From: Dennis Bauer Date: Sat, 14 Mar 2026 13:59:01 +0100 Subject: [PATCH 2/3] Solved the problem --- Problems/Seven-Boom/seven-boom.test.ts | 2 +- Problems/Seven-Boom/solver.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Problems/Seven-Boom/seven-boom.test.ts b/Problems/Seven-Boom/seven-boom.test.ts index 654adf2..3824e90 100644 --- a/Problems/Seven-Boom/seven-boom.test.ts +++ b/Problems/Seven-Boom/seven-boom.test.ts @@ -7,7 +7,7 @@ describe("Determines the correct count of sevens in the array", () => { }); it("should return 'there is no 7 in the array' for the second array", () => { - expect(sevenBoom([8, 6, 33, 100])).toEqual("there is not 7 in the array"); + expect(sevenBoom([8, 6, 33, 100])).toEqual("there is no 7 in the array"); }); it("should return one 'Boom' for the third array", () => { diff --git a/Problems/Seven-Boom/solver.ts b/Problems/Seven-Boom/solver.ts index 46be114..cc591d5 100644 --- a/Problems/Seven-Boom/solver.ts +++ b/Problems/Seven-Boom/solver.ts @@ -1,3 +1,9 @@ export default function sevenBoom(array: number[]): string { - throw new Error("Solution yet not implemented!"); + const sevenCount = array + .join("") + .split("") + .reduce((count, current) => (current === "7" ? count + 1 : count), 0); + + if (sevenCount === 0) return "there is no 7 in the array"; + else return "Boom! ".repeat(sevenCount).trim(); } From 9ee53e24a87aedc25e559b026ee029d2f860591a Mon Sep 17 00:00:00 2001 From: Dennis Bauer Date: Sat, 14 Mar 2026 14:05:42 +0100 Subject: [PATCH 3/3] Finished the problem --- Problems/Seven-Boom/README.md | 28 ++++++++++++++++++++++++++-- README.md | 5 +++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Problems/Seven-Boom/README.md b/Problems/Seven-Boom/README.md index a8da127..3cebe3e 100644 --- a/Problems/Seven-Boom/README.md +++ b/Problems/Seven-Boom/README.md @@ -10,13 +10,37 @@ If e.g there is a `77` in the array, the count of 7's needs to increase by two. ### Solution Idea -The Idea to solve this problem +First, combine all numbers into a single string. +Then count how many times the digit `"7"` appears in that string. + +- If the count is `0`, return that there is no `"7"`. +- If the count is greater than `0`, return `"Boom!"` repeated as many times as the digit `"7"` appears. --- ### [Implementation](./solver.ts) -The implementation for solving this problem +First, the array is joined into a single string using `array.join("")`. +Then we split the string again with `split("")`, which results in an array containing every single digit. + +Next, we use `reduce` to count how many times the digit `"7"` appears. +The reducer keeps track of the current count of sevens. + +If the current value is `"7"`, we increase the counter by 1. +Otherwise, we return the counter unchanged. + +Example reducer: + +.reduce((count, current) => (current === "7" ? count + 1 : count), 0) + +After this step, we have the total number of `"7"` digits stored in `sevenCount`. + +Finally, we check the value of this counter: + +- If it is `0`, we return the message that there is no `"7"`. +- If it is greater than `0`, we return `"Boom!"` repeated `sevenCount` times using: + +`"Boom! ".repeat(sevenCount).trim();` --- diff --git a/README.md b/README.md index 7d58c23..0901ee3 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: **25 problems** +Solved: **26 problems** -🟢 Easy: 19 +🟢 Easy: 20 🟠 Medium: 5 🔴 Hard: 1 @@ -41,6 +41,7 @@ Solved: **25 problems** | [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 | +| [Seven Boom!](./Problems/Seven-Boom/README.md) | 🟢 Easy |