Skip to content

Commit

Permalink
How good are you really?
Browse files Browse the repository at this point in the history
  • Loading branch information
PheRum committed Jun 15, 2024
1 parent f42ae27 commit 69da647
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
14 changes: 14 additions & 0 deletions 8_kyu/How good are you really?/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## How good are you really?

https://www.codewars.com/kata/5601409514fc93442500010b

There was a test in your class and you passed it. Congratulations!

But you're an ambitious person. You want to know if you're better than the average student in your class.

You receive an array with your peers' test scores. Now calculate the average and compare your score!

Return true if you're better, else false!

Note:
Your points are not included in the array of your class's points. Do not forget them when calculating the average score!
23 changes: 23 additions & 0 deletions 8_kyu/How good are you really?/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { betterThanAverage } from "./index";

describe("Tests", () => {
it("betterThanAverage([2, 3], 5) should return True", () => {
expect(betterThanAverage([2, 3], 5)).toBe(true);
});

it("betterThanAverage([100, 40, 34, 57, 29, 72, 57, 88], 75) should return True", () => {
expect(betterThanAverage([100, 40, 34, 57, 29, 72, 57, 88], 75)).toBe(true);
});

it("betterThanAverage([12, 23, 34, 45, 56, 67, 78, 89, 90], 9) should return False", () => {
expect(betterThanAverage([12, 23, 34, 45, 56, 67, 78, 89, 90], 9)).toBe(false);
});

it("betterThanAverage([41, 75, 72, 56, 80, 82, 81, 33], 50) should return False", () => {
expect(betterThanAverage([41, 75, 72, 56, 80, 82, 81, 33], 50)).toBe(false);
});

it("betterThanAverage([29, 55, 74, 60, 11, 90, 67, 28], 21) should return False", () => {
expect(betterThanAverage([29, 55, 74, 60, 11, 90, 67, 28], 21)).toBe(false);
});
});
5 changes: 5 additions & 0 deletions 8_kyu/How good are you really?/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function betterThanAverage(classPoints: number[], yourPoints: number): boolean {
const average = classPoints.reduce((a, b) => a + b, 0) / classPoints.length;

return average <= yourPoints;
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### Katas solved

`Total`: 94 \
`8_kyu`: 77 \
`Total`: 95 \
`8_kyu`: 78 \
`7_kyu`: 13 \
`6_kyu`: 4 \
`5_kyu`: 0 \
Expand Down
1 change: 0 additions & 1 deletion kata.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
8 kyu - How good are you really? - https://www.codewars.com/kata/5601409514fc93442500010b
8 kyu - Simple multiplication - https://www.codewars.com/kata/583710ccaa6717322c000105
8 kyu - Convert a String to a Number! - https://www.codewars.com/kata/544675c6f971f7399a000e79
8 kyu - CSV representation of array - https://www.codewars.com/kata/5a34af40e1ce0eb1f5000036
Expand Down

0 comments on commit 69da647

Please sign in to comment.