6 kyu

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
Arrays
Strings
Fundamentals

Stats:

CreatedDec 4, 2017
PublishedDec 20, 2017
Warriors Trained300
Total Skips12
Total Code Submissions863
Total Times Completed116
Java Completions116
Total Stars7
% of votes with a positive feedback rating96% of 34
Total "Very Satisfied" Votes32
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes1
Total Rank Assessments4
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • alotau Avatar
  • Blind4Basics Avatar
  • flaco Avatar
Ad