# The Miscalculator [closed]

Inspired by a post I saw on social media, your job is to create a miscalculator (aka "wrongulator"): a calculator which always outputs the wrong answer!

# Challenge

Write a program that inputs a string or text file of individual expressions such as:

5*7,
21/3, or
11-3


And returns a wrong answer for the expression (in this case, anything except for 35, 7, and 8 in that order). To simplify the task a little, the input must only be one operator at a time.

• The program will emulate a basic calculator, so it should be able to handle addition, subtraction, multiplication and division.

• The output must be "reasonably" believable:

5 + 6 = 20 and
5 + 6 = -1 are allowed, but
5 + 6 = 3.18888, 2453139, or -258 are all not.

• The outputs must not be easily predictable (eg, simply adding one to the correct result every time), and cannot use any random number functionality your language has. (But can use the built-in functions for square roots etc.) Otherwise the method of producing the wrong answer is up to you.

• Consistency is a major plus, so that the same expression is liable to always output the same wrong answer.

• The output can either be as a single number or as an equation.

# Test Cases and Examples

For example, I might have the following program:

1. If the operation is addition or subtraction a +/- b, it adds or subtracts floor(a/6) to ceiling(b/6) and multiplies that by 6. If either number is divisible by 6, then we compute 6*(floor(x/5.9) +/- ceil(x/5.9)):

5 + 9 "=" 12 (real answer is 14)
49 + 36 "=" 90 (real answer is 85). Here 36 is a multiple of 6, so we use the second formula.
21 - 11 "=" 12 (real answer is 10)
4 - 26 "=" -30 (real answer is -22)

2. If the operation is multiplication, a*b, it computes (a-0.3)*(b-0.4) and rounds down, then adds ceil((a + b)/2) for good measure.

5*9 "=" 47 (real is 45)
11*(-23) "=" -256 (real is -253)

3. If the operation is division, a/b, it simply computes abs((a-0.3)/(b-0.4)), then tacks on the sign of the original expression (so that if 0 < a < 0.3, for example, the expression won't change sign):

(-12/14) "=" -0.904... (real is -0.857...)
183/11 "=" 17.236... (real is 16.636...)


This is a , so the most popular/creative answer wins.

## closed as off-topic by cat, Blue, Rɪᴋᴇʀ, Zach Gates, rink.attendant.6May 7 '16 at 17:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Questions without an objective primary winning criterion are off-topic, as they make it impossible to indisputably decide which entry should win." – cat, Blue, Rɪᴋᴇʀ, Zach Gates, rink.attendant.6
If this question can be reworded to fit the rules in the help center, please edit the question.

• Allowing only a subset of mathematical operations is a good start. – Optimizer Jul 8 '15 at 20:28
• What kind of idiot believes that 5 + 6 = -1?! – Beta Decay Jul 8 '15 at 20:42
• What if they mistook the + for a -? "Oh I might have clicked the wrong button"? – Jacob Jul 8 '15 at 20:43
• I feel like this would be better as an underhanded. – Maltysen Jul 9 '15 at 23:09
• This challenge might be more interesting if: 1. The calculator usually returns the correct result, but mysteriously breaks for some types or input. 2. It's not immediately obvious by looking at the source code why this happens. – Dennis Jul 10 '15 at 4:30

## Python 3

# init
the,calculation,evaluated,its,result,of=int,oct,eval,111,'',lambda x:x+1

# do the magic here
print(the(calculation(of(the(evaluated(input())))).translate({its:result})))

• this is awesome. – cat Dec 1 '15 at 16:09

## Python 2.7

print int(input()**0.5*0.9+1)


Takes square root, multiplies by 0.9, adds one, and makes it an integer.

It's simple really. Always prints "'", ' is never used in an equation (I don't think).

• The output is not reasonably believable – TanMath Dec 1 '15 at 6:17

# Python3

print(int(str(eval(input()))[::-1])+2)


puts(eval(gets.chomp)+1)