The below shape consist of $24$ segments with unit length. if we want to draw this shape without lifting the pen, what is the minimum length of the line we should draw?
$1)25\quad\quad\quad\quad\quad\quad2)26\quad\quad\quad\quad\quad\quad3)27\quad\quad\quad\quad\quad\quad4)28\quad\quad\quad\quad\quad\quad5)29\quad\quad\quad\quad\quad\quad$

I think we can do it somehow by segments with the length $28$ (by passing twice the four middle segments on each side of outer big square).
I'm not sure how to solve this problem. is it possible to solve it mathematically or I should just try different ways to draw this?





The figure has 4 nodes with 2 lines connected to node. 8 nodes with 3 lines connected, and 4 nodes with 4 lines connected.
If you want to complete the circuit without lifting your pen, you can start at a node with an odd number of connections, and you can end at a node with an odd number of connections, for all the rest you must have an even number of connections. That is, if you get to the node on one path you leave the node on a different path.
This means that you must double up on some of the lines where it appears that there is a odd number of lines to make it an even number. What is the minimum number of lines you need to double up such that there are at most two nodes with an odd number of connections?