# Two naughty programmers

The math professor wrote an equation f(x) = x and defined t as number of solutions at f(x) = 5 and u as number of solutions at f(x) = 3. He further defines N as N = t+u

Two programmers decided to edit mathematical equations in a computer belonging to math professor. The first programmer designed a software that takes the absolute value of the function every 2 minute starting from 1st minute, the second programmer designed another program that subtracted 5 from the resulting equation every 2 minutes, starting from 2nd minute. For instance, a function f(x) = 3x-4 will look like, abs(abs(3x-4) - 5) after 3 minutes.

Professor left the computer open for some time, and returns back to check the value of N, he finds the value of N increased by 84 and then decreased by 84 in 3 consecutive minutes. After how many minutes did he return?

Around 56 minutes

Because

On minute 1 the function becomes abs(x). A big V shape standing on the y=0 line. It has 2 solution for both t and u.
On minute 2 the function decreases by 5. Still a V but standing on the y=-5 line. Still 2 solution for both equations.
On minute 3 the bottom of the V shape is folded up. Now we have a big W between the y=0 and y=5 line.

From there on every even minute shifts the function down and every odd minute folds the bottom of the function, adding a zig and a zag between lines y=0 and y=5.

Graphically:

 /
0:_____/____
 /

 \ /
1:____\/____

2:___\__/___
 \/

 \ /
3:___\/\/___

4:__\____/__
 \/\/

 \ /
5:__\/\/\/__

6:_\______/_
 \/\/\/

 \ /
7:_\/\/\/\/_

This brings to..

The solutions for t are the tops of the zig-zags on odd minutes, 2 on even minutes.
The sequence for t is: 1, 2, 2, 3, 2, 4, 2, 5, 2, 6, ...

The solutions for u are the number of zigs and zags on odd minutes, 2 on even minutes.
The sequence for u is: 1, 2, 2, 4, 2, 6, 2, 8, 2, 10, ...

The sequence for the sum N is: 2, 4, 4, 7, 4, 10, 4, 13, 4, ...
The delta is 2, 0, 3, -3, 6, -6, 9, -9, 12, -12, ...

Continuing the sequence we have:
minute 55, N=85, delta=+81
minute 56, N = 4, delta=+81
minute 57, N=88, delta=+84
minute 58, N = 4, delta=-84

The professor observed the changes on minute 57 and 58, so he returned between the 56th an 57th minute. Since he left between the 0th and the 1st minute, the absence is around 56 minutes.