Statistics

Problem Statement for "BearCheats"

Problem Statement

Limak is an old brown bear. Because of his bad eyesight he sometimes has to visit his doctor, Dr. Carrot. Today is one such day.


Dr. Carrot has a blackboard in his office. There is a number A written on the blackboard. In order to examine Limak's eyesight, Dr. Carrot asked him to read the number. Limak couldn't see the number really well. He could determine the number of digits correctly, but he was not sure what the individual digits are. Finally, he decided to announce the number B to the doctor. The doctor then left the office for a short while.


Limak really doesn't want to wear glasses, so he has decided to cheat. As soon as the doctor left the room, Limak went to the blackboard to read the correct number A. Before the doctor returns, Limak has the time to change one of the digits of A to any different digit. (Note that he may not add any new digits to A and he may not completely erase any digits of A. He may only change at most one of the digits.) Limak hopes that he can deceive the doctor by changing the number A into his number B.


You are given the ints A and B. Return the String "happy" (quotes for clarity) if Limak can convince the doctor that his eyesight is good. Otherwise, return the String "glasses".

Definition

Class:
BearCheats
Method:
eyesight
Parameters:
int, int
Returns:
String
Method signature:
String eyesight(int A, int B)
(be sure your method is public)

Constraints

  • A and B will be between 1 and 999,999, inclusive.
  • A and B will have the same number of digits.

Examples

  1. 8072

    3072

    Returns: "happy"

    Limak wants to change 8072 into 3072. He can do that by changing the digit 8 to a 3.

  2. 508

    540

    Returns: "glasses"

    Limak would need to change two digits, but he only has the time to change at most one.

  3. 854000

    854000

    Returns: "happy"

    It is possible that Limak read the number correctly. If that happens, he will not change any digits.

  4. 1

    6

    Returns: "happy"

  5. 385900

    123000

    Returns: "glasses"

  6. 1

    1

    Returns: "happy"

  7. 99

    99

    Returns: "happy"

  8. 98

    89

    Returns: "glasses"

  9. 222

    323

    Returns: "glasses"

  10. 654321

    123456

    Returns: "glasses"

  11. 848097

    848997

    Returns: "happy"

  12. 50000

    10000

    Returns: "happy"

  13. 1111

    1011

    Returns: "happy"

  14. 999758

    999758

    Returns: "happy"

  15. 879000

    889000

    Returns: "happy"

  16. 59390

    58391

    Returns: "glasses"

  17. 278548

    276348

    Returns: "glasses"

  18. 109

    110

    Returns: "glasses"

  19. 1000

    1089

    Returns: "glasses"

  20. 12

    22

    Returns: "happy"

  21. 12121

    22222

    Returns: "glasses"

  22. 11

    23

    Returns: "glasses"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: