Question 1089843: The function f(x,y) accepts an ordered pair as input and gives another ordered pair as output. It is defined according to the following rules: If x > 4, f(x,y) = (x - 4,y). If x <= 4 but y > 4, f(x,y) = (x,y - 4). Otherwise, f(x,y) = (x + 5, y + 6). A robot starts by moving to the point (1,1). Every time it arrives at a point (x,y), it applies f to that point and then moves to f(x,y). If the robot runs forever, how many different points will it visit?
Answer by jim_thompson5910(35256) (Show Source):
You can put this solution on YOUR website!
Rule 1: If x > 4 then use f(x,y) = (x-4, y)
Rule 2: If x <= 4 and y > 4 then use f(x,y) = (x, y - 4)
Rule 3: If neither condition of rule 1 or rule 2 apply, then use f(x,y) = (x + 5, y + 6)
----------------------------------------------
This is one of those type of problems where you need to walk things through one step at a time.
The initial input is (1,1). The goal is to see when we arrive back at this point. Once we come back to (1,1), things will loop again and no new unique points will be visited.
Let's start the walk-through.
Initial point = (x,y) = (1,1)
----------------------------------------------
move #1:
f(x,y) = (x+5, y+6) ... (x,y) = (1,1) doesn't satisfy rule 1 or rule 2, use rule 3
f(1,1) = (1+5, 1+6)
f(1,1) = (6,7)
So we've gone from (1,1) to (6,7)
----------------------------------------------
move #2:
f(x,y) = (x-4, y) ... x = 6 is larger than 4, so use rule 1
f(6,7) = (6-4, 7)
f(6,7) = (2,7)
So we've gone from (6,7) to (2,7)
----------------------------------------------
move #3:
f(x,y) = (x, y-4) ... x = 2 and y = 7 satisfy x <= 4 and y > 4 respectively, so use rule 2
f(2,7) = (2, 7-4)
f(2,7) = (2,3)
So we've gone from (2,7) to (2,3)
----------------------------------------------
move #4:
f(x,y) = (x+5, y+6) ... (x,y) = (2,3) doesn't satisfy rule 1 or rule 2, use rule 3
f(2,3) = (2+5, 3+6)
f(2,3) = (7,9)
So we've gone from (2,3) to (7,9)
----------------------------------------------
move #5:
f(x,y) = (x-4, y) ... x = 7 is larger than 4, so use rule 1
f(7,9) = (7-4, 9)
f(7,9) = (3,9)
So we've gone from (7,9) to (3,9)
----------------------------------------------
move #6:
f(x,y) = (x, y-4) ... x = 3 and y = 9 satisfy x <= 4 and y > 4 respectively, so use rule 2
f(3,9) = (3, 9-4)
f(3,9) = (3,5)
So we've gone from (3,9) to (3,5)
----------------------------------------------
move #7:
f(x,y) = (x, y-4) ... x = 3 and y = 5 satisfy x <= 4 and y > 4 respectively, so use rule 2
f(3,5) = (3, 5-4)
f(3,5) = (3,1)
So we've gone from (3,5) to (3,1)
----------------------------------------------
move #8:
f(x,y) = (x+5, y+6) ... (x,y) = (3,1) doesn't satisfy rule 1 or rule 2, use rule 3
f(3,1) = (3+5, 1+6)
f(3,1) = (8,7)
So we've gone from (3,1) to (8,7)
----------------------------------------------
move #9:
f(x,y) = (x-4, y) ... x = 8 is larger than 4, so use rule 1
f(8,7) = (8-4, 7)
f(8,7) = (4,7)
So we've gone from (8,7) to (4,7)
----------------------------------------------
move #10:
f(x,y) = (x, y-4) ... x = 4 and y = 7 satisfy x <= 4 and y > 4 respectively, so use rule 2
f(4,7) = (4, 7-4)
f(4,7) = (4,3)
So we've gone from (4,7) to (4,3)
----------------------------------------------
move #11:
f(x,y) = (x+5, y+6) ... (x,y) = (4,3) doesn't satisfy rule 1 or rule 2, use rule 3
f(4,3) = (4+5, 3+6)
f(4,3) = (9,9)
So we've gone from (4,3) to (9,9)
----------------------------------------------
move #12:
f(x,y) = (x-4, y) ... x = 9 is larger than 4, so use rule 1
f(9,9) = (9-4, 9)
f(9,9) = (5,9)
So we've gone from (9,9) to (5,9)
----------------------------------------------
move #13:
f(x,y) = (x-4, y) ... x = 5 is larger than 4, so use rule 1
f(5,9) = (5-4, 9)
f(5,9) = (1,9)
So we've gone from (5,9) to (1,9)
----------------------------------------------
move #14:
f(x,y) = (x, y-4) ... x = 1 and y = 9 satisfy x <= 4 and y > 4 respectively, so use rule 2
f(1,9) = (1, 9-4)
f(1,9) = (1,5)
So we've gone from (1,9) to (1,5)
----------------------------------------------
move #15:
f(x,y) = (x, y-4) ... x = 1 and y = 5 satisfy x <= 4 and y > 4 respectively, so use rule 2
f(1,5) = (1, 5-4)
f(1,5) = (1,1)
So we've gone from (1,5) to (1,1)
Since we arrived back at (1,1) -- the initial point -- we can stop the walk-through.
After this point, the steps will loop.
----------------------------------------------
----------------------------------------------
In summary, we started at (1,1) and did a total of 15 moves.
Overall, there are 15 unique points.
The 15 points are:
Point1 | (1,1) | Point2 | (6,7) | Point3 | (2,7) | Point4 | (2,3) | Point5 | (7,9) | Point6 | (3,9) | Point7 | (3,5) | Point8 | (3,1) | Point9 | (8,7) | Point10 | (4,7) | Point11 | (4,3) | Point12 | (9,9) | Point13 | (5,9) | Point14 | (1,9) | Point15 | (1,5) |
Therefore, the answer is 15.
If you exclude the initial point (1,1) then the answer would be 14.
|
|
|