Skip to main content
Edit down to a stub to save space
Source Link
naffetS
  • 12.8k
  • 1
  • 10
  • 17

Eh, codegolf shmodegolf

Has been posted here!

This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:

  • word -> word shmord
  • baby -> baby shmaby
  • sale -> sale shmale

Rules

In the real world there are a bunch of special cases, but for this challenge we will use rules that describe a simplified version of the full linguistic phenomenon that is more suitable for programming:

  1. Consonants up to first vowel are replaced by "shm".
  2. Prepend shm to words beginning with vowels.
  3. If a word contains no vowels it is returned unchanged. No vowel, no shm.
  4. The vowels are: a, e, i, o, u.
  5. The input will be restricted to lowercase letters.
  6. The output should be a string containing the the reduplicated version of the input. If the input is "string" the output should be "shming".

This is code golf, shortest code wins!

Example solution (ungolfed python)

This is an example of code that would solve the challenge:

def function_shmunction(string):
    vowels = "aeiou"
    for letter in string:
        if letter in vowels:
            index = string.index(letter)
            shming = "shm" + string[index:]
            return shming
    return string

Test casesEh, codegolf shmodegolf

  • function -> shmunction
  • stellar -> shmellar
  • atypical -> shmatypical
  • wwwhhhat -> shmat
  • aaaaaaaaaa -> shmaaaaaaaaaa
  • lrr -> lrr

Eh, codegolf shmodegolf

Has been posted here!

This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:

  • word -> word shmord
  • baby -> baby shmaby
  • sale -> sale shmale

Rules

In the real world there are a bunch of special cases, but for this challenge we will use rules that describe a simplified version of the full linguistic phenomenon that is more suitable for programming:

  1. Consonants up to first vowel are replaced by "shm".
  2. Prepend shm to words beginning with vowels.
  3. If a word contains no vowels it is returned unchanged. No vowel, no shm.
  4. The vowels are: a, e, i, o, u.
  5. The input will be restricted to lowercase letters.
  6. The output should be a string containing the the reduplicated version of the input. If the input is "string" the output should be "shming".

This is code golf, shortest code wins!

Example solution (ungolfed python)

This is an example of code that would solve the challenge:

def function_shmunction(string):
    vowels = "aeiou"
    for letter in string:
        if letter in vowels:
            index = string.index(letter)
            shming = "shm" + string[index:]
            return shming
    return string

Test cases

  • function -> shmunction
  • stellar -> shmellar
  • atypical -> shmatypical
  • wwwhhhat -> shmat
  • aaaaaaaaaa -> shmaaaaaaaaaa
  • lrr -> lrr
Added link to the post on the main codegolf forum.
Source Link
JSorngard
  • 973
  • 5
  • 4

Eh, codegolf shmodegolf

Has been posted here!

This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:

  • word -> word shmord
  • baby -> baby shmaby
  • sale -> sale shmale

Rules

In the real world there are a bunch of special cases, but for this challenge we will use rules that describe a simplified version of the full linguistic phenomenon that is more suitable for programming:

  1. Consonants up to first vowel are replaced by "shm".
  2. Prepend shm to words beginning with vowels.
  3. If a word contains no vowels it is returned unchanged. No vowel, no shm.
  4. The vowels are: a, e, i, o, u.
  5. The input will be restricted to lowercase letters.
  6. The output should be a string containing the the reduplicated version of the input. If the input is "string" the output should be "shming".

This is code golf, shortest code wins!

Example solution (ungolfed python)

This is an example of code that would solve the challenge:

def function_shmunction(string):
    vowels = "aeiou"
    for letter in string:
        if letter in vowels:
            index = string.index(letter)
            shming = "shm" + string[index:]
            return shming
    return string

Test cases

  • function -> shmunction
  • stellar -> shmellar
  • atypical -> shmatypical
  • wwwhhhat -> shmat
  • aaaaaaaaaa -> shmaaaaaaaaaa
  • lrr -> lrr

Eh, codegolf shmodegolf

This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:

  • word -> word shmord
  • baby -> baby shmaby
  • sale -> sale shmale

Rules

In the real world there are a bunch of special cases, but for this challenge we will use rules that describe a simplified version of the full linguistic phenomenon that is more suitable for programming:

  1. Consonants up to first vowel are replaced by "shm".
  2. Prepend shm to words beginning with vowels.
  3. If a word contains no vowels it is returned unchanged. No vowel, no shm.
  4. The vowels are: a, e, i, o, u.
  5. The input will be restricted to lowercase letters.
  6. The output should be a string containing the the reduplicated version of the input. If the input is "string" the output should be "shming".

This is code golf, shortest code wins!

Example solution (ungolfed python)

This is an example of code that would solve the challenge:

def function_shmunction(string):
    vowels = "aeiou"
    for letter in string:
        if letter in vowels:
            index = string.index(letter)
            shming = "shm" + string[index:]
            return shming
    return string

Test cases

  • function -> shmunction
  • stellar -> shmellar
  • atypical -> shmatypical
  • wwwhhhat -> shmat
  • aaaaaaaaaa -> shmaaaaaaaaaa
  • lrr -> lrr

Eh, codegolf shmodegolf

Has been posted here!

This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:

  • word -> word shmord
  • baby -> baby shmaby
  • sale -> sale shmale

Rules

In the real world there are a bunch of special cases, but for this challenge we will use rules that describe a simplified version of the full linguistic phenomenon that is more suitable for programming:

  1. Consonants up to first vowel are replaced by "shm".
  2. Prepend shm to words beginning with vowels.
  3. If a word contains no vowels it is returned unchanged. No vowel, no shm.
  4. The vowels are: a, e, i, o, u.
  5. The input will be restricted to lowercase letters.
  6. The output should be a string containing the the reduplicated version of the input. If the input is "string" the output should be "shming".

This is code golf, shortest code wins!

Example solution (ungolfed python)

This is an example of code that would solve the challenge:

def function_shmunction(string):
    vowels = "aeiou"
    for letter in string:
        if letter in vowels:
            index = string.index(letter)
            shming = "shm" + string[index:]
            return shming
    return string

Test cases

  • function -> shmunction
  • stellar -> shmellar
  • atypical -> shmatypical
  • wwwhhhat -> shmat
  • aaaaaaaaaa -> shmaaaaaaaaaa
  • lrr -> lrr
Moved io restrictions into the numbered list of rules for clarity
Source Link
JSorngard
  • 973
  • 5
  • 4

Eh, codegolf shmodegolf

This challenge is a very unbaked idea about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:

  • word -> word shmord
  • baby -> baby shmaby
  • sale -> sale shmale

Rules

TheseIn the real world there are a bunch of special cases, but for this challenge we will use rules that describe a simplified version of the full linguistic phenomenon that is more suitable for programming:

  1. Consonants up to first vowel are replaced by "shm".
  2. Prepend shm to words beginning with vowels.
  3. If a word contains no vowels it is returned unchanged. No vowel, no shm.
  4. The vowels are: a, e, i, o, u.
  5. The input will be restricted to lowercase letters.
  6. The output should be a string containing the the reduplicated version of the input. If the input is "string" the output should be "shming".

The input will be restricted to lowercase letters.
The output should be a string containing the the reduplicated version of the input. If the input is "string" the output should be "shming".

This is code golf, shortest code wins!

Example solution (ungolfed python)

This is an example of code that would solve the challenge, as currently defined.:

def function_shmunction(string):
    vowels = "aeiou"
    for letter in string:
        if letter in vowels:
            index = string.index(letter)
            shming = "shm" + string[index:]
            return shming
    return string

Test cases

  • function -> shmunction
  • stellar -> shmellar
  • atypical -> shmatypical
  • wwwhhhat -> shmat
  • aaaaaaaaaa -> shmaaaaaaaaaa
  • lrr -> lrr

Eh, codegolf shmodegolf

This is a very unbaked idea about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:

  • word -> word shmord
  • baby -> baby shmaby
  • sale -> sale shmale

Rules

These rules describe a simplified version of the full linguistic phenomenon that is more suitable for programming:

  1. Consonants up to first vowel are replaced by "shm".
  2. Prepend shm to words beginning with vowels.
  3. If a word contains no vowels it is returned unchanged. No vowel, no shm.
  4. The vowels are: a, e, i, o, u.

The input will be restricted to lowercase letters.
The output should be a string containing the the reduplicated version of the input. If the input is "string" the output should be "shming".

This is code golf, shortest code wins!

Example solution (ungolfed python)

This is an example of code that would solve the challenge, as currently defined.

def function_shmunction(string):
    vowels = "aeiou"
    for letter in string:
        if letter in vowels:
            index = string.index(letter)
            shming = "shm" + string[index:]
            return shming
    return string

Test cases

  • function -> shmunction
  • stellar -> shmellar
  • atypical -> shmatypical
  • wwwhhhat -> shmat
  • aaaaaaaaaa -> shmaaaaaaaaaa
  • lrr -> lrr

Eh, codegolf shmodegolf

This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:

  • word -> word shmord
  • baby -> baby shmaby
  • sale -> sale shmale

Rules

In the real world there are a bunch of special cases, but for this challenge we will use rules that describe a simplified version of the full linguistic phenomenon that is more suitable for programming:

  1. Consonants up to first vowel are replaced by "shm".
  2. Prepend shm to words beginning with vowels.
  3. If a word contains no vowels it is returned unchanged. No vowel, no shm.
  4. The vowels are: a, e, i, o, u.
  5. The input will be restricted to lowercase letters.
  6. The output should be a string containing the the reduplicated version of the input. If the input is "string" the output should be "shming".

This is code golf, shortest code wins!

Example solution (ungolfed python)

This is an example of code that would solve the challenge:

def function_shmunction(string):
    vowels = "aeiou"
    for letter in string:
        if letter in vowels:
            index = string.index(letter)
            shming = "shm" + string[index:]
            return shming
    return string

Test cases

  • function -> shmunction
  • stellar -> shmellar
  • atypical -> shmatypical
  • wwwhhhat -> shmat
  • aaaaaaaaaa -> shmaaaaaaaaaa
  • lrr -> lrr
Boldened Test cases heading
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading
Added acknowledgement that this is not actually the complete "shm-reduplication" phenomenon
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading
Changed output format
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading
Added output format restrictions
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading
Moved description of input being lowercase to a better location
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading
code humour
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading
Clarified challenge rules. Corrected code to solve challenge
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading
Removed crossed out text, added more test cases, specified what should be done if the input has no vowels
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading
Corrected code whitespace
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading
Crossed out initialisms
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading
Added example solution, added restrictions to input
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading
Source Link
JSorngard
  • 973
  • 5
  • 4
Loading