-5
\$\begingroup\$

Thank you for you help fixing my calculator's multiply function, but I've found another critical error all calculators seem to share. None of them understand that 2+2=fish. So now I need code to properly add 2 numbers.

Challenge

  • Take 2 numbers as input (Type doesn't matter, but only 2 items will be passed. This is addition, so order obviously doesn't matter.)
  • Output sum of both numbers except if they are both 2, then output fish (case insensitive)
    • PS. I never was really good with counting, so I think only Integers from 0 to 99 are real numbers (Type used doesn't matter)
  • Fewest bytes per language wins!

(NOTE: The key difference between this challenge and the previous, is that order is now irrelevant, and the return type is not restricted to int, which has major implications for type safe languages like Java. You can also see in the answers already here that in non type strict languages like Python, this rule set can dramatically change the answer code.)

\$\endgroup\$
4
  • 3
    \$\begingroup\$ Not sure why this is getting reopen votes - this is clearly a duplicate. \$\endgroup\$ Commented Sep 20, 2017 at 19:51
  • 2
    \$\begingroup\$ @DigitalTrauma It's a fuzzy line between duplicate, and sufficiently different to be interesting. While answers from the other question COULD be altered to answer this one as well, most of them will not be winning answers. I'm guess the side of the line people are on might be based on if they think they know how they could do it better under these new conditions. \$\endgroup\$
    – Tezra
    Commented Sep 20, 2017 at 19:59
  • \$\begingroup\$ [...] has major implications for type safe languages like Java. I don't think making I/O more annoying is a good thing. It certainly doesn't prevent the challenge from being a duplicate. \$\endgroup\$
    – Dennis
    Commented Sep 21, 2017 at 2:40
  • \$\begingroup\$ @Dennis The fact that this got enough votes to reopen means that a number of people disagree that this is a duplicate. And it's called a "challenge" for a reason, little changes in the obstacles can require dramatically different solutions. So I don't think you can really complain about the added challenge. Compare the 2 answers here to the same language solutions in the other challenge to prove my point. \$\endgroup\$
    – Tezra
    Commented Sep 21, 2017 at 14:24

2 Answers 2

1
\$\begingroup\$

Python 2, 33 bytes

lambda x,y:x==y==2and"fish"or x+y

Try it online!

\$\endgroup\$
1
1
\$\begingroup\$

C (gcc), 30 bytes

f(x,y){x=x^y&&x^2?x+y:"fish";}

Try it online!

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.