codingk8 / codeWars_Numbers_WCS_Bootcamp

Wild Code School CodeWars package about numbers :skull:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

codeWars_Numbers_WCS_Bootcamp

Wild Code School CodeWars package about numbers πŸ’€

Last update: 20190121


Recap


Item 41 Basic Mathematical Operations ☁️

Your task is to create a function that does four basic mathematical operations.
The function should take three arguments - operation(string/char), value1(number), value2(number).
The function should return result of numbers after applying the chosen operation.

Play

Check

Item 42 Count of positives / sum of negatives πŸ™

Play

Check

Look at the filter solution here
Compare and contrast Map(), Filter() and Reduce() πŸ˜‰

Item 43 Invert values 🐨

Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives.

invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5]
invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5]
invert([]) == []

You can assume that all values are integers.

Hints: deal with the empty array first, then think about the 0 that should not become -0

Play

Check

Hint: the map() with 2 ternary operators inside πŸ’ƒ

Item 44 Breaking Chocolate Problem 🍫

Your task is to split the chocolate bar of given dimension n x m into small squares. Each square is of size 1x1 and unbreakable. Implement a function that will return minimum number of breaks needed.
For example if you are given a chocolate bar of size 2 x 1 you can split it to single squares in just one break, but for size 3 x 1 you must do two breaks.
If input data is invalid you should return 0 (as in no breaks are needed if we do not have any chocolate to split). Input will always be a non-negative integer.

Play

Check

Hint:

Item 45 (soon)

Item 46 (soon)

Item 47 (soon)

Item 48 (soon)

Item 49 (soon)

Item 410 (soon)


OK, let's move it πŸ˜‰

Boo


About

Wild Code School CodeWars package about numbers :skull:


Languages

Language:JavaScript 100.0%