Skip to content

Commit

Permalink
Well of Ideas - Easy Version
Browse files Browse the repository at this point in the history
  • Loading branch information
PheRum committed May 19, 2024
1 parent 9da9504 commit 757edc1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
8 changes: 8 additions & 0 deletions 8_kyu/Well of Ideas - Easy Version/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Well of Ideas - Easy Version

https://www.codewars.com/kata/57f222ce69e09c3630000212

For every good kata idea there seem to be quite a few bad ones!

In this kata you need to check the provided array (x) for good ideas 'good' and bad ideas 'bad'. If there are one or two good ideas,
return 'Publish!', if there are more than 2 return 'I smell a series!'. If there are no good ideas, as is often the case, return 'Fail!'.
9 changes: 9 additions & 0 deletions 8_kyu/Well of Ideas - Easy Version/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { well } from "./index";

describe("Tests", () => {
it("example", () => {
expect(well(["bad", "bad", "bad"])).toBe("Fail!");
expect(well(["good", "bad", "bad", "bad", "bad"])).toBe("Publish!");
expect(well(["good", "bad", "bad", "bad", "bad", "good", "bad", "bad", "good"])).toBe("I smell a series!");
});
});
13 changes: 13 additions & 0 deletions 8_kyu/Well of Ideas - Easy Version/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
type WellType = "good" | "bad";

export function well(x: WellType[]) {
const good = x.filter((n) => n === "good").length;

if (good && good <= 2) {
return "Publish!";
}
if (good > 2) {
return "I smell a series!";
}
return "Fail!";
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

### Katas solved

`Total`: 39 \
`8_kyu`: 37 \
`Total`: 40 \
`8_kyu`: 38 \
`7_kyu`: 0 \
`6_kyu`: 2 \
`5_kyu`: 0 \
Expand Down

0 comments on commit 757edc1

Please sign in to comment.