2 digit average calculation

How to calculate the average of 2 digits using a brain injection?

I mean, I have two digits, for example 2 3 and its average value is 2.5

for 2 8 we have 5.0

How can I do that?

+4
source share
2 answers

Something along the lines of:

 ++>++++++++< this is input data [<+>-] this adds the numbers <[[->+<][->>+<<]] this does the calculation 

The approach is to evenly distribute the sum of two numbers. By means of a uniform distribution, I mean that the difference between the values ​​is not more than 1 (since there are no floating point numbers, you must somehow represent, for example, 2.5). When you have two neighboring cells containing these values, feel free to do whatever you want with them (you can print them and then reduce the numbers from each cell, and if you stay with 1, then print ".5" by him).

Of course, the code above may have pointer errors, but it should be enough to start and debug. In addition, I would be very happy to see a good, effective solution.

+2
source

the best solution:

 ,>, //input 1 and 2 >++++++[-<--------<-------->>]<< //decrement both by 48 [->+<]>>++< //add them and then put 2 in the third cell(devisor) [ // ... >[->+>+<<] >[-<<- [>]>>>[<[>>>-<<<[-]]>>]<<] //integer division (4/2 = 2, 3/2 = 1...) >>>+ <<[-<<+>>] <<<] >[-]>>>>[-<<<<<+>>>>>] //... <<<<++++++[-<++++++++>]<. //increment 28 and print result 
+1
source

All Articles