Jump to content

Recommended Posts

Posted

I was working trying to figure out how to map input to output and came up with this program.

def create_mapping_function(inputData, outputData):
    mapping = []
    # map the same to the same
    for i in range(0,len(inputData)):
        for o in range(0,len(outputData)):
            if outputData[o] == inputData[i]:
                # mapping position to position
                # this shows the mapping values.
                mapping.append([i,o])
    return mapping
inputData = input_data()
outputData = output_data()


mapping = create_mapping_function(inputData, outputData)

# print(f)

# use mapping and save them as a mapping function.

inputData    = ['h','e','l','l','o']

# mapping   = f
# # input a unique list with a specific length
#f(x)
def mapping_function(inputData, mapping):
    outputData = []
    for i in range(0,len(inputData)):
        outputData.append(0) # placeholders

    for i in range(0,len(inputData)):
        outputData[mapping[i][1]] = inputData[mapping[i][0]]

    return outputData

output = mapping_function(inputData, mapping)
print(output)

What it is doing to taking an input and output and then finding there common relationships.

Afterwards it outputs the mapping with user define input.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.