Surreal Numbers Construction Rule
Description:
There is a neat number system called "Surreal Numbers." You can read about them here: https://en.wikipedia.org/wiki/Surreal_number.
This kata focuses on the definition of a surreal number in terms of a form. A form is a pair of sets of numbers, L
and R
, written as follows:
{ L | R }
From wikipedia: A form { L | R } is numeric if the intersection of L and R is the empty set and each element of R is greater than every element of L.
Given two strings of space-separated numbers representing L and R, determine if { L | R }
would represent a surreal number by returning a boolean.
All numbers in the supplied string are either integers or ratios of integers and may be positive or negative. For negative ratios, the minus sign is always the first symbol and there is at most one minus sign per number. One or both strings may be empty and in this case the form represents a valid surreal number and isSurreal should return true
.
Examples:
isSurreal("-1", "1") = true
isSurreal("1", "-1") = false
isSurreal("1/2", "3/4") = true
isSurreal("-3 -2 -1 0", "17") = true
isSurreal("18 33 -2 19 -1/8", "99 34 200/3") = true
isSurreal("18 33 -2 19 1/8", "99 31 200/3") = false
isSurreal("-3", "-2 65") = true
Similar Kata:
Stats:
Created | Dec 4, 2017 |
Published | Dec 20, 2017 |
Warriors Trained | 300 |
Total Skips | 12 |
Total Code Submissions | 863 |
Total Times Completed | 116 |
Java Completions | 116 |
Total Stars | 7 |
% of votes with a positive feedback rating | 96% of 34 |
Total "Very Satisfied" Votes | 32 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 4 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |