DNPotapov / Codewars-katas-

0 stars 0 forks source link

Caffeine Script (7 kyu) #18

Open DNPotapov opened 1 year ago

DNPotapov commented 1 year ago
def caffeine_buzz(n):
    return "mocha_missing!" if n%3!=0 else "CoffeeScript" if n%2+n%3+n%4==0 else "JavaScript" if n%2+n%3==0 else "Java"
DNPotapov commented 1 year ago

Complete the function caffeineBuzz, which takes a non-zero integer as its argument.

If the integer is divisible by 3, return the string "Java".

If the integer is divisible by 3 and divisible by 4, return the string "Coffee"

If one of the condition above is true and the integer is even, add "Script" to the end of the string.

If none of the condition is true, return the string "mocha_missing!"

caffeineBuzz(1) => "mocha_missing!" caffeineBuzz(3) => "Java" caffeineBuzz(6) => "JavaScript" caffeineBuzz(12) => "CoffeeScript"

DNPotapov commented 1 year ago

https://www.codewars.com/kata/5434283682b0fdb0420000e6