Reputation: 69
If I have
string1: 1000 characters, 100 ones
0001000000010000010100000000000000100010000000000000000000000010100000001100100000000000101000010000001000100000000010000001001000000000000000000000000010000000000000000000000000000000001010001000000000000000000010000001000000000000000000001000000000000000000000000000000001001000000000000000000000000010001000000011000000000010000000010000000010000000001000010000000000010000000000000000000000000000000000000000001000000000000000001000000010000100000010010000000000000000000010000000000000010000000000000100000001000010100000001100000000100000010010100000000000001000110000000110001000100000000000010000000100000000000000000010000000000000000000000010000000000000000000000100000000000001000000110000000000000000001000000000000000000000000010000000000100000000010000000100010000000100000000000000000010000000000000000000010000000000100010000000000000000000000111110000000100000000000011000001000000000000000000010000000000000100000001000000100000000000010010000010000000000000000001000100000000000000
string2: 1000 characters, 30 ones
0000001000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000100000000000000001000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000001000000000000000000000000001100000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000010000000000000000000000000000000101000010000000000000000000000000000100100000000000001000000000000000010000000001000000000000010000001000000000000000000000000010000000000000000000000000000000000000000100000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000001100000000000000000000000000000000000000000000000000
The goal is to align the thirty ones in string2 with any thirty ones in string1, i.e., modify string2 with a modification key so that the 30 ones in string2 match 30 ones in string1.
The key should allow for reversing the modification of string2 to return it to its original form.
In other words I want to write three functions:
make_key(string1, string2) -> key
encode(string2, key) -> string2'
decode(string2', key) -> string2
such that string2' has 30 ones at positions which are ones in string1.
The key should consist of digits from 0 to 9 and should not exceed 20 digits in length.
I have tried rotating string2 among itself, searching for patterns, removing groups of zeros, and shuffling, but none of these methods have worked for me.
What I am really looking for is the approach of how to achieve it, then I would generate the algorithm code. It could be a mathematical solution, but there could also be some ingenious, lateral thinking solution, like finding a way to eliminate common zeros in both strings, or creating a motion snake that loops through the ones in a specific way, etc. I have tried different strategies, but without satisfactory results.
Any help you can provide is greatly appreciated. Thank you.
Upvotes: 2
Views: 102