It's not working 100% but for most basic cases it does, first of all I check if the word passed is inside the fruits list, if not i iterate through each character of the shortest word and I subtract with abs (so that the result is always positive) the value of the characters with the Ord function, then I add the difference of word lengths.
It is kind of a own metric that is not very thinked but it worked to me for these simple tests.
Finally I select as a result the word containing the less value of the metrics I calculated.
After completing the challenge this way I read about levenstein function, it may be a better way to do this.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here it goes a python one :
I compare by the distances of each char and give less importance to length
plzz explain ur code to me ...
It's not working 100% but for most basic cases it does, first of all I check if the word passed is inside the fruits list, if not i iterate through each character of the shortest word and I subtract with abs (so that the result is always positive) the value of the characters with the Ord function, then I add the difference of word lengths.
It is kind of a own metric that is not very thinked but it worked to me for these simple tests.
Finally I select as a result the word containing the less value of the metrics I calculated.
After completing the challenge this way I read about levenstein function, it may be a better way to do this.