Interfacing between technophile and technophobe

NACTF2020 – Dr. J’s Vegetable Factory #2

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 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”

Avocado, Brocolli, Eggplant, Daikon Radish, Carrot

  1. (swap 3 and 4)

Avocado, Brocolli, Eggplant, Carrot, Daikon Radish

  1. (swap 2 and 3)

Avocado, Brocolli, Carrot, Eggplant, Daikon Radish

  1. (swap 3 and 4)

Avocado, Brocolli, Carrot, Daikon Radish, Eggplant

  • 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()
info = s.recv(4096).decode("utf-8")
#increase received bytes
response = s.recv(8192).decode("utf-8")
stripList = response.split("\n\n")[1].split(', ')
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):
            stripList[j], stripList[j + 1] = stripList[j + 1], stripList[j]
# add \n to return
trackString = " ".join(trackSort) + "\n"
response = s.recv(8192).decode("utf-8")

This spits out the flag:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: