Beta
Unicode Math
21zebulan
Description:
In this kata, you must write a function that returns the result of simple mathematical operations on the characters with implicit values of a unicode string.
This function takes two arguments:
- a unicode string of random characters
- this string will always be unicode and at least two valid characters long
- a random list of operation functions (addition, multiplication and subtraction)
- this list will never be empty and will only ever contain the three functions listed above (randomly ordered)
If/when you run out of operations to apply, you must start at the beginning of the list of operations again.
Examples
unicode_math(u'12', [lambda a, b: a + b]) == 3
unicode_math(u'123', [lambda a, b: a + b]) == 6
unicode_math(u'1234', [lambda a, b: a + b, lambda c, d: c - d]) == 4
unicode_math(u'a1b2', [lambda a, b: a - b]) == -1
unicode_math(u'\uff17\uff20\uff15\uff12', [lambda a, b: a * b]) == 70
unicode_math('3½', [lambda a, b: a + b]) == 3.5
If you have any feedback, feel free to leave a comment and/or raise an issue!
HINT
Unicode
Fundamentals
Similar Kata:
Stats:
Created | Nov 19, 2016 |
Published | Nov 19, 2016 |
Warriors Trained | 120 |
Total Skips | 23 |
Total Code Submissions | 284 |
Total Times Completed | 21 |
Python Completions | 21 |
Total Stars | 1 |
% of votes with a positive feedback rating | 75% of 10 |
Total "Very Satisfied" Votes | 7 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 11 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |