I recently took a coding test for a promotion at work. This was one of the tasks I really struggled with and was wondering what is the best way to do this. I used a load of
For places, AB:CD
,
If at any point a condition cannot be fulfilled:
return NOT POSSIBLE
If there are two numbers greater than 5:
place the larger in B, smaller in D
for non-filled places from left to right:
if B > 3:
place a 1 in A
else:
place the largest number smaller than 3 in A
if A is 2:
place the largest number smaller than 4 in B
else:
place the largest number in B
place the largest number smaller than 6 in C
place the remaining number in D