In this kata, your task is to write a function that returns the smallest and largest integers in an unsorted string. In this kata, a range is considered a finite sequence of consecutive integers.
Your function will receive two arguments:- A
string
comprised of integers in an unknown range; think of this string as the result when a range of integers is shuffled around in random order then joined together into a string - An
integer
value representing the size of the range
input_string = '1568141291110137'
mystery_range(input_string, 10) # [6, 15]
# The 10 numbers in this string are:
# 15 6 8 14 12 9 11 10 13 7
# Therefore the range of numbers is from 6 to 15
let inputString = '1568141291110137';
mysteryRange(inputString, 10) // [6, 15]
// The 10 numbers in this string are:
// 15 6 8 14 12 9 11 10 13 7
// Therefore the range of numbers is from 6 to 15
inputString := "1568141291110137"
MysteryRange(inputString, 10) // [6 15]
// The 10 numbers in this string are:
// 15 6 8 14 12 9 11 10 13 7
// Therefore the range of numbers is from 6 to 15
# For Elixir, return a tuple
input_string = "1568141291110137"
KataSolution.mystery_range(input_string, 10) # {6, 15}
# The 10 numbers in this string are:
# 15 6 8 14 12 9 11 10 13 7
# Therefore the range of numbers is from 6 to 15
string input_string = "1568141291110137";
KataSolution.MysteryRange(input_string, 10); // [6, 15]
// The 10 numbers in this string are:
// 15 6 8 14 12 9 11 10 13 7
// Therefore the range of numbers is from 6 to 15
input_string = '1568141291110137'
mystery_range(input_string, 10) # [6, 15]
# The 10 numbers in this string are:
# 15 6 8 14 12 9 11 10 13 7
# Therefore the range of numbers is from 6 to 15
- The maximum size of a range will be
100
integers - The starting number of a range will be:
0 < n < 100
- Full Test Suite:
21
fixed tests,100
random tests - Use Python 3+ for the Python translation
- For JavaScript,
require
has been disabled and most built-in prototypes have been frozen (prototype methods can be added toArray
andFunction
) - All test cases will be valid
If you enjoyed this kata, be sure to check out my other katas