7 kyu

Say Me Please Operations

257 of 1,400hubencu_st

Description:

You have a string of numbers; starting with the third number each number is the result of an operation performed using the previous two numbers.

Complete the function which returns a string of the operations in order and separated by a comma and a space, e.g. "subtraction, subtraction, addition"

The available operations are (in this order of preference):

1) addition
2) subtraction
3) multiplication
4) division

Notes:

  • All input data is valid
  • The number of numbers in the input string >= 3
  • For a case like "2 2 4" - when multiple variants are possible - choose the first possible operation from the list (in this case "addition")
  • Integer division should be used

Example

"9 4 5 20 25"  -->  "subtraction, multiplication, addition"

Because:

9 - 4 = 5   --> subtraction
4 * 5 = 20  --> multiplication
5 + 20 = 25 --> addition
Algorithms
Logic
Strings
Lists

Similar Kata:

More By Author:

Check out these other kata created by hubencu_st

Stats:

CreatedJul 29, 2018
PublishedJul 29, 2018
Warriors Trained3128
Total Skips68
Total Code Submissions8471
Total Times Completed1400
C# Completions257
Python Completions633
JavaScript Completions493
Ruby Completions57
Total Stars42
% of votes with a positive feedback rating90% of 275
Total "Very Satisfied" Votes229
Total "Somewhat Satisfied" Votes37
Total "Not Satisfied" Votes9
Total Rank Assessments24
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • hubencu_st Avatar
  • anter69 Avatar
  • B1ts Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • topping Avatar
  • Just4FunCoder Avatar
Ad