Skip to main content
Post Undeleted by greybeard
bloop!
Source Link
greybeard
  • 6.5k
  • 3
  • 20
  • 52

The biggest problem with the code presented is that it does not document what it is to accomplish:
See how your take and MatBailie's do a substitution based on the position in a/the sequence of vowels where others substitute based on the order of vowels in the string.

It would be simpler to just manipulate the string instead of converting to and from list - benchmark.

In addition to using a set to test case-normalised characters, one could use a set containing each vowel in lower as well as upper case.

One could establish the set of vowels used, but the time save in "the substitution pass" is probably less than what's added in preprocessing.

Alternatives: Iterate from both sides concurrently exchanging vowels "on the fly".
When you reach the middle vowel, you're done -
problem: establishing you've reached the middle vowel.

establishEstablish sequence of vowels and its reverse,
find and substitute each.

The biggest problem with the code presented is that it does not document what it is to accomplish:
See how your take and MatBailie's do a substitution based on the position in a/the sequence of vowels where others substitute based on the order of vowels in the string.

It would be simpler to just manipulate the string instead of converting to and from list - benchmark.

In addition to using a set to test case-normalised characters, one could use a set containing each vowel in lower as well as upper case.

One could establish the set of vowels used, but the time save in "the substitution pass" is probably less than what's added in preprocessing.

Alternatives: Iterate from both sides concurrently exchanging vowels "on the fly".
When you reach the middle vowel, you're done -
problem: establishing you've reached the middle vowel.

establish sequence of vowels and its reverse,
find and substitute each.

The biggest problem with the code presented is that it does not document what it is to accomplish:
See how your take and MatBailie's do a substitution based on the position in a/the sequence of vowels where others substitute based on the order of vowels in the string.

In addition to using a set to test case-normalised characters, one could use a set containing each vowel in lower as well as upper case.

One could establish the set of vowels used, but the time save in "the substitution pass" is probably less than what's added in preprocessing.

Alternatives: Iterate from both sides concurrently exchanging vowels "on the fly".
When you reach the middle vowel, you're done -
problem: establishing you've reached the middle vowel.

Establish sequence of vowels and its reverse,
find and substitute each.

Post Deleted by greybeard
Source Link
greybeard
  • 6.5k
  • 3
  • 20
  • 52

The biggest problem with the code presented is that it does not document what it is to accomplish:
See how your take and MatBailie's do a substitution based on the position in a/the sequence of vowels where others substitute based on the order of vowels in the string.

It would be simpler to just manipulate the string instead of converting to and from list - benchmark.

In addition to using a set to test case-normalised characters, one could use a set containing each vowel in lower as well as upper case.

One could establish the set of vowels used, but the time save in "the substitution pass" is probably less than what's added in preprocessing.

Alternatives: Iterate from both sides concurrently exchanging vowels "on the fly".
When you reach the middle vowel, you're done -
problem: establishing you've reached the middle vowel.

establish sequence of vowels and its reverse,
find and substitute each.