I need to made a formula for a software, and I can use only these functions/operarions.

The input values range for this process is from 0 to 9. The input values are inserted random.

I want that if the input value is <5, the output of the formula is the value just inserted. Else, it must outputs the last output value.

For example, if the sequence is:

1 6 3 2 7 4 9...

the output must be

1 1 3 2 2 4 4...

Unfortunatly, I need to write this formula in one line expression. There isn't any memory/assignation available.

Is it possible do this with a simple math process? "Keeping" in some way a value with the available functions listed above?

  • $\begingroup$ Can't you use the A/B/C knobs as memory? $\endgroup$ – Memming Jan 16 '14 at 15:26

What you want is not possible, a function is a map $f: A \rightarrow B$.

That means you assign every element $a \in A$ an unique element $f(a) \in B$.

A function doesn't have any memory, in particular it can't remember the last argument it was evaluated at.

| cite | improve this answer | |

Do you want to code the problem ? In C the code is as follows :

while( scanf("%d",&n) )
   n = (n<5)?prev:n;
   prev = n ; 
| cite | improve this answer | |
  • $\begingroup$ As I said, I can't do any assignement, and prev = n is! $\endgroup$ – markzzz Jan 16 '14 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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