This is a fairly simple code golf challenge. Your program, given an ASCII string, is to parse that string into two strings, which it will evaluate. If the second string is "later" than the first one, it will return a 1, if it is "earlier" than the first one, it will return a -1, and if they are the same, it will return 0. To clarify what "later" and "earlier" mean, let's take a look at ASCII character codes. You need to compare each character of the string, treating each of them as digits of a number. Later refers to a larger number, occurring after a smaller number. Strings will be formatted with a hyphen character to separate the two input groups.
Take a look at this example:
7-9
as an input should return1
.
7
converts to ASCII code55
, and9
converts to ASCII code57
.As
57
occurs numerically after55
,9
is later than7
.
Another example:
LKzb-LKaj
as an input should return-1
The ASCII code sequences for this are
76-75-122-98
and76-75-97-106
This is a code golf challenge, and byte count is how entries will be scored.
Any input from the 95 printable ASCII characters is accepted, excluding spaces, and hyphens for anything but separating the input. In addition, strings are not guaranteed to be the same length.
Good luck!
EDIT: To be more clear, each character is to be treated like a digit in a number. In the example LKzb-LKaj
, though j
is later than b
, z
is later than a
, and since it is a more significant digit, it takes precedence. A string supplied will always be at minimum 3 characters, eliminating empty strings from the scope of this problem.
EDIT: Here are some more test cases, for your help:
A-9
->-1
11-Z
->-1
3h~J*-3h~J*
->0
Xv-Y0
->1
11-Z
->-1
makes no sense given the current wording of the question.Z
(90) is greater than1
(49) and is the most significant letter. Please clarify how strings of different lengths are compared. \$\endgroup\$A-AA
? \$\endgroup\$11>Z
in your examples when1<Z
. There must be some undefined behaviour to do with strings of differing lengths or the example is wrong. \$\endgroup\$~
at 126, then would increment the next digit by one, returning the initial digit to!
. Each increase in the most significant digit is equivalent to increment the second-most-significant digit by 127. \$\endgroup\$