Beta

Unicode Math

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

More By Author:

Check out these other kata created by zebulan

Stats:

CreatedNov 19, 2016
PublishedNov 19, 2016
Warriors Trained120
Total Skips23
Total Code Submissions284
Total Times Completed21
Python Completions21
Total Stars1
% of votes with a positive feedback rating75% of 10
Total "Very Satisfied" Votes7
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes2
Total Rank Assessments11
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • zebulan Avatar
Ad