- Oct 6, 2020
- 2,626
- 9,931
I need to improve a function of mine and the task is interesting enough to be posted under HAF as a challenge to see who can do it.
The task is to make a replacement of a random char in the string with its replacement only once and replacement selection must be randomized.
So approx steps should be:
- we take a random key/value pair from $map
- we find if there is a match to key in the string, if not, take another key/value pair
- we find a random word where we will make the replacement but make sure its not listed in $skip
- we do the replacement of a single char and return the string
Results that must be produced every time calling the function on the string:
//bhw 1s the most popular marketing forum out there.
//bhw is the most popular market1ng forum out there.
//bhw is the m0st popular marketing forum out there.
//bhw is the most popular marketing forum 0ut there.
//bhw is the most+popular marketing forum out there.
See how the replacement is randomized and done only once and skipping bhw keyword?
I don't want the solution to be long & ugly.
If you can't make it impressive and beautiful, please do not apply.
The solution should be an easy drop-in function.
Budget - $30 and my thanks. If it's too low, state your own budget.
Happy to pay with paypal, payoneer or whatever.
I do not use skype and please - only Jr. VIP members reach out to me, I will ignore people without the ability to sell on forums.
The task is to make a replacement of a random char in the string with its replacement only once and replacement selection must be randomized.
$input = 'bhw is the most popular marketing forum out there.';
$map = [
'i' => '1',
'o' => '0',
'b' => '3',
' ' => '+'
];
$skip = ['bhw'];
So approx steps should be:
- we take a random key/value pair from $map
- we find if there is a match to key in the string, if not, take another key/value pair
- we find a random word where we will make the replacement but make sure its not listed in $skip
- we do the replacement of a single char and return the string
Results that must be produced every time calling the function on the string:
//bhw 1s the most popular marketing forum out there.
//bhw is the most popular market1ng forum out there.
//bhw is the m0st popular marketing forum out there.
//bhw is the most popular marketing forum 0ut there.
//bhw is the most+popular marketing forum out there.
See how the replacement is randomized and done only once and skipping bhw keyword?
I don't want the solution to be long & ugly.
The solution should be an easy drop-in function.
Budget - $30 and my thanks. If it's too low, state your own budget.
Happy to pay with paypal, payoneer or whatever.
I do not use skype and please - only Jr. VIP members reach out to me, I will ignore people without the ability to sell on forums.