Let $S$ be the [set](https://artofproblemsolving.com/wiki/index.php/Set) of [points](https://artofproblemsolving.com/wiki/index.php/Point) in the [Cartesian plane](https://artofproblemsolving.com/wiki/index.php/Cartesian_plane) that satisfy $\Big|\big||x|-2\big|-1\Big|+\Big|\big||y|-2\big|-1\Big|=1.$ If a model of $S$ were built from wire of negligible thickness, then the total length of wire required would be $a\sqrt{b}$, where $a$ and $b$ are positive integers and $b$ is not divisible by the square of any prime number. Find $a+b$.
Solution 1 (non-rigorous)
Let $f(x) = \Big|\big||x|-2\big|-1\Big|$, $f(x) \ge 0$. Then $f(x) + f(y) = 1 \Longrightarrow f(x), f(y) \le 1 \Longrightarrow x, y \le 4$. We only have a $4\times 4$ area, so guessing points and graphing won't be too bad of an idea. Since $f(x) = f(-x)$, there's a symmetry about all four [quadrants](https://artofproblemsolving.com/wiki/index.php/Quadrant), so just consider the first quadrant. We now gather some points:



$f(1) = 0$
$f(0.1) = 0.9$


$f(2) = 1$
$f(0.9) = 0.1$


$f(3) = 0$
$f(1.1) = 0.1$


$f(4) = 1$
$f(1.9) = 0.9$


$f(0.5) = 0.5$
$f(2.1) = 0.9$


$f(1.5) = 0.5$
$f(2.9) = 0.1$


$f(2.5) = 0.5$
$f(3.1) = 0.1$


$f(3.5) = 0.5$
$f(3.9) = 0.9$

We can now graph the pairs of coordinates which add up to $1$. Just using the first column of information gives us an interesting [lattice](https://artofproblemsolving.com/wiki/index.php?title=Lattice&action=edit&redlink=1) pattern:
[1997 AIME-13a.png](https://artofproblemsolving.com/wiki/index.php/File:1997_AIME-13a.png)
Plotting the remaining points and connecting lines, the graph looks like:
[1997 AIME-13b.png](https://artofproblemsolving.com/wiki/index.php/File:1997_AIME-13b.png)
Calculating the lengths is now easy; each rectangle has sides of $\sqrt{2}, 3\sqrt{2}$, so the answer is $4(\sqrt{2} + 3\sqrt{2}) = 16\sqrt{2}$. For all four quadrants, this is $64\sqrt{2}$, and $a+b=\boxed{066}$.

Solution 2
Since $0 \le \Big|\big||x| - 2\big| - 1\Big| \le 1$ and $0 \le \Big|\big||y| - 2\big| - 1\Big| \le 1$
$- 1 \le \big||x| - 2\big| - 1 \le 1$
$0 \le \big||x| - 2\big| \le 2$
$- 2 \le |x| - 2 \le 2$
$- 4 \le x \le 4$
Also $- 4 \le y \le 4$.
Define $f(a) = \Big|\big||a| - 2\big| - 1\Big|$.

If $0 \le a \le 1$:
$f(3 + a) = \Big|\big||3 + a| - 2\big| - 1\Big| = a$
$f(3 - a) = \Big|\big||3 - a| - 2\big| - 1\Big| = a$
$f(3 + a) = f(3 - a)$
If $0 \le a \le 2$:
$f(2 + a) = \Big|\big||2 + a| - 2\big| - 1\Big| = a - 1$
$f(2 - a) = \Big|\big||2 - a| - 2\big| - 1\Big| = a - 1$
$f(2 + a) = f(2 - a)$
If $0 \le a \le 4$:
$f(a) = \Big|\big||a| - 2\big| - 1\Big| = a - 3$
$f( - a) = \Big|\big|| - a| - 2\big| - 1\Big| = a - 3$
$f(a) = f( - a)$
So the graph of $y(x)$ at $3 \le x \le 4$ is symmetric to $y(x)$ at $2 \le x \le 3$ (reflected over the line x=3)
And the graph of $y(x)$ at $2 \le x \le 4$ is symmetric to $y(x)$ at $0 \le x \le 2$ (reflected over the line x=2)
And the graph of $y(x)$ at $0 \le x \le 4$ is symmetric to $y(x)$ at $- 4 \le x \le 0$ (reflected over the line x=0)
[this is also true for horizontal reflection, with $3 \le y \le 4$, etc]
So it is only necessary to find the length of the function at $3 \le x \le 4$ and $3 \le y \le 4$:
$\Big|\big||x| - 2\big| - 1\Big| + \Big|\big||y| - 2\big| - 1\Big| = 1$
$x - 3 + y - 3 = 1$
$y = - x + 7$
(Length = $\sqrt {2}$)
This graph is reflected over the line y=3, the quantity of which is reflected over y=2,

the quantity of which is reflected over y=0,
the quantity of which is reflected over x=3,
the quantity of which is reflected over x=2,
the quantity of which is reflected over x=0..
So a total of $6$ doublings = $2^6$ = $64$, the total length = $64 \cdot \sqrt {2} = a\sqrt {b}$, and $a + b = 64 + 2 = \boxed{066}$.

Solution 3 (FASTEST)
We make use of several consecutive substitutions. 
Let $||x| - 2|= x_1$ and similarly with $y$.
Therefore, our graph is $|x_1 - 1| + |y_1 - 1| = 1$. This is a rhombus with perimeter $4\sqrt{2}$. Now, we make use of the following fact for a function of two variables $x$ and $y$: Suppose we have $f(x, y) = c$. Then $f(|x|, |y|)$ is equal to the graph of $f(x, y)$ reflected across the y axis and x axis, and the reflection across the y axis across the x axis, therefore the perimeter of  of $f(|x|, |y|)$ is 4 times the perimeter of $f(x, y)$. Now, we continue making substitutions at each absolute value sign ($|x| - 2 = x_2$ and finally $x = x_3$, similarly for y as well. ),  noting that the constants don't matter as they just translate the graph and each absolute value sign increases the perimeter 4 times as much. Therefore, the length is $4^2 \times 4\sqrt{2} = 64\sqrt{2} = a\sqrt{b}$, and $a+b = \boxed{066}$.
- whatRthose

Solution 4 (Exploiting intuitions about absolute value with linear functions)
In a similar manner to the other posted solutions, we want to find the length of just a piece of this monstrosity and then figure out what fraction of the entire function that piece represents. It's possible to go right for the smallest possible piece that'll help us by letting $a = \big||x|-2\big|-1$ and $b = \big||y|-2\big|-1$. We then get that $b = 1 - a$ (obviously the other way would work too). One specific "case" here is the one where all the numbers in the absolute value bars are positive, and thus where $b = 1 - x - 2 = -x - 1$. Since we're dealing with compounded absolute values, we can infer that the piece we just found has to be bounded by the two axes; the length of this piece also won't be affected by the constants that are hidden in $b$. Using the Pythagorean Theorem / distance formula, that tiny length comes out to be $\sqrt{2}$. 
Because we're working with linear terms only, the presence of each absolute value bar will double the length of the function's graph at each step as we work backward to our original equation. As there are six absolute value bars to be added back in (three on each side), we find that there are $2^6$ of these pieces of length $\sqrt{2}$, making our answer $2 + 64 = \boxed{066}$.
~ anellipticcurveoverq