Compare Two Strings Lexicographically
Two branch libraries are merging their catalogues, and the merge tool has to decide for each pair of titles which one belongs first on the shelf. Shelf order is dictionary order: compare the first letters, move to the second letters if the first ones match, and so on. A word that runs out while still matching comes first.
Task: Read two words and report where the first sits relative to the second in dictionary order.
Input
Two lines. Line 1 holds the first word, line 2 holds the second. Each is 1 to 100 lower-case letters, with no spaces.
Output
One line holding exactly Less if the first word comes before the second, exactly Greater if it comes after, or exactly Equal if the two are identical. Capital first letter, no quotes.
Example:
Input:
apple
banana
Output:
Less
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in