kris-classes / restart

2022 Semester 2 Course Topics
10 stars 7 forks source link

Codewars challenges #30

Open krp opened 1 year ago

krp commented 1 year ago

https://www.codewars.com/

Silverchain07 commented 1 year ago

Problem: https://www.codewars.com/kata/5287e858c6b5a9678200083c/train/python

issues: sum of power of values was not compiling through the array. Code error: using =+ instead of '+='

SOLVED

Silverchain07 commented 1 year ago

Problem: https://www.codewars.com/kata/5390bac347d09b7da40006f6/train/python

Taking a break to prep for first day Internship.

vickie142 commented 1 year ago

https://www.codewars.com/kata/55fd2d567d94ac3bc9000064/train/python

def row_sum_odd_numbers(n):

your code here

return n ** 3

(n) is the input value, (**) is the power, like x^ of (3) which outputs the sum.

SOLVED

vickie142 commented 1 year ago

https://www.codewars.com/kata/57a0885cbb9944e24c00008e/train/python

Remove Exclamation Marks

def remove_exclamation_marks(s):

your code here

return s.replace("!","")

(return) is needed to return the solution, if not then it won't make the changes needed to solve it. (s.replace("!","") s.replace will replace ("!" into "") which effectively removes !

This effectively could replace/change any word into another word.

SOLVED

vickie142 commented 1 year ago

https://www.codewars.com/kata/50654ddff44f800200000004/train/python

This brings up the importance of a return function. Hint Hint

SOLVED

vickie142 commented 1 year ago

https://www.codewars.com/kata/55685cd7ad70877c23000102/train/python

Return Negative:

Original Code:

def make_negative( number ): if number < 0: return number return number * -1

Simple to understand. If the number is anything lower than 0, it just returns the number. The last code returns a number and multiplies a negative one which just turns the original number into a negative number.

Once finished, I discovered in the solutions that there is another easier way to solve it which includes (abs). No idea what it was about so I investigated (abs)olute) value and it refers to how far away the number is from zero, regardless of whether the number is positive or negative.

abs(value) will forever return a positive number but what about -abs(value)?

SOLVED

vickie142 commented 1 year ago

https://www.codewars.com/kata/57f609022f4d534f05000024/train/python

Find a stray number.

SOLVED