## mrn00b0t

#### Interfacing between technophile and technophobe

This is my solution to the NACTF2020 Challenge “Dr. J’s Vegetable Factory #2”.

After years of collecting plush vegetable toys, Dr. J decided to take on his true passion: starting a vegetable factory. Dr. J is incredibly organized, so he likes all of his vegetables to be in the proper order. In fact, he built a robot “Turnipinator-1000” to alphabetize his vegetables for him! Unfortunately, Dr. J doesn’t know what instructions to give Turnipinator-1000. Can you help him out? 🥬🥕🌽🍆🥦🥒🥑🍄

`nc challenges.ctfd.io 30267`

Give instructions in the form of numbers separated by spaces. Entering the number x will swap the vegetable in position x with the vegetable in position x+1. Positions start at zero, not one. (Dr. J is a programmer after all.) For example, given the following vegetables: Avocado, Brocolli, Eggplant, Daikon Radish, Carrot, one possible solution is “3 2 3”

1. (swap 3 and 4)

1. (swap 2 and 3)

1. (swap 3 and 4)

• The20thDuck

Dr. J expanded his vegetable factory and he’s got hundreds of vegetables. Can you give Turnipinator-1000 the right instructions to sort Dr. J’s vegetables? 🥬🥕🌽🍆🥦🥒🥑🍄

The challenge is solved with the following Python code:

```import socket
s = socket.socket()
s.connect(("challenges.ctfd.io",30267))
info = s.recv(4096).decode("utf-8")
print(info)
s.send(b'2\n')
response = s.recv(8192).decode("utf-8")
print(response)
stripList = response.split("\n\n")[1].split(', ')
print(stripList)
sortedList = sorted(stripList)
trackSort = []
while stripList != sortedList:
for j in range(len(stripList) - 1):
testList = [stripList[j], stripList[j + 1]]
if [stripList[j], stripList[j + 1]] == sorted(testList):
continue
else:
stripList[j], stripList[j + 1] = stripList[j + 1], stripList[j]
trackSort.append(str(j))