Skip to content

Commit

Permalink
Merge pull request #153 from MikeBeloborodov/7_kyu_word_values
Browse files Browse the repository at this point in the history
word values
  • Loading branch information
MikeBeloborodov committed Jun 9, 2024
2 parents cada289 + 08b6ee8 commit a6bb6b9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions 7_kyu/word_values/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Word values

https://www.codewars.com/kata/598d91785d4ce3ec4f000018

![description](./description.jpg "Description")
Binary file added 7_kyu/word_values/description.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions 7_kyu/word_values/word_values.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { wordValue } from "./word_values";

describe("test cases", () => {
it("should return [88, 12 225]", () =>
expect(wordValue(["codewars", "abc", "xyz"])).toStrictEqual([88, 12, 225]));
});
9 changes: 9 additions & 0 deletions 7_kyu/word_values/word_values.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const wordValue = (a: string[]): number[] =>
a.map(
(item, index) =>
(index + 1) *
item
.replace(/\s/g, "")
.split("")
.reduce((sum, val) => sum + val.charCodeAt(0) - 96, 0),
);
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ npm run push "$description"

### Katas solved

`Total`: 155
`Total`: 156
\
`8_kyu`: 51
\
`7_kyu`: 53
`7_kyu`: 54
\
`6_kyu`: 38
\
Expand Down

0 comments on commit a6bb6b9

Please sign in to comment.