Hi, I’m not sure what level of detail would be required for the pseudocode but this was my take on it:
Thanks Tomas