Scott Logic Interview Question

what does this pseudocode do? (sorting algorithm) Three-Hat puzzle Mislabeled jars puzzle