Daily Code Challenge #4
- Biyi Akinpelu
- Feb 5, 2023
- 1 min read
There are N couples sitting in a row of length 2 * N. They are currently ordered randomly, but would like to rearrange themselves so that each couple's partners can sit side by side.
What is the minimum number of swaps necessary for this to happen?

You can attempt at this challenge here.
Bonus Challenge
What does the below code snippet print out? How can we fix the anonymous functions to behave as we'd expect?
functions = []
for i in range(10):
functions.append(lambda : i)
for f in functions:
print(f())
Comments