This is the fewest portals and shifts I managed.
There's a trade off to have one shift less at the cost of one portal more, but I prioritized portals over shifts.
I still haven't managed to crack the code yet, though.
EDIT: got the code!
EDIT2: someone on Krzyhau's Discord managed 14 portals 41 shifts to completion, 2 shifts less than my best