7 kyu
Give me a Crazy Formula!
208 of 296Arthur GC
Description:
Given a non-negative number, sum all its digits using the following rules:
If the number of digits is even, remove the last digit
a. If the middle digit is odd, subtract it instead of adding
b. If both the middle digit and the last digit are even, subtract the last digit instead of adding
c. If the middle digit is even but the last digit is odd, the first digit must be squared
Repeat this process until only 1 digit is left.
Note: if at some point the number becomes negative, remove the minus sign.
Examples
5 => 5
214 => 2 - 1 + 4 = 5 => 5
126 => 1 + 2 - 6 = -3 => 3
2234 => 223 => 2^2 + 2 + 3 = 9 => 9
Mathematics
Algorithms
Puzzles
Similar Kata:
Stats:
Created | Dec 4, 2015 |
Published | Dec 4, 2015 |
Warriors Trained | 966 |
Total Skips | 58 |
Total Code Submissions | 1218 |
Total Times Completed | 296 |
C# Completions | 95 |
Python Completions | 208 |
Total Stars | 20 |
% of votes with a positive feedback rating | 91% of 97 |
Total "Very Satisfied" Votes | 82 |
Total "Somewhat Satisfied" Votes | 12 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 8 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |