Skip to main content
Complete sentences start with a capital letter
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37

Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English!

Your task is to write a program or function that takes a string as input, and then returns or prints the golfed version. There will be no newlines or tabs in the input.

This is how you golf a string. The order matters!

  1. removeRemove spaces directly before and after punctuation: "Hey there", he said ; he ' s a cat. -> "Hey there",he said;he's a cat. The following count as punctuation: .,?!"':;()

  2. replaceReplace he/she/it is, case insensitive, with he's/she's/it's: It is unfortunate that she is not coming ever. -> It's unfortunate that she's not coming ever.

  3. wordsWords that start with capital letters in a sentence can be moved against the preceding word (omitting the space): The farmer told Fred that he should leave. -> The farmer toldFred that he should leave.

  4. trailingTrailing and leading spaces should be removed: [ ]It's raining.[ ]-> It's raining. Ignore the brackets (annoying auto-formatting).

  5. Remove repeated punctuation that is the same: ""Here''s the cake",, said Fred..! -> "Here's the cake",saidFred.!

If we were to golf the first paragraph of this challenge, the output would be:

Everybody loves golfing code.Code is written inEnglish(eh.).Therefore,everybody loves golfingEnglish!

This is code golf––or rather English golf––so shortest code in bytes wins!


Here is one all encompassing test case:

Input: " You are crazy"",, , , she said. It is unfortunate that Margaret had to say that... she is a Martian!.
Output: "You are crazy",she said.It's unfortunate thatMargaret had to say that.she's aMartian!.

Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English!

Your task is to write a program or function that takes a string as input, and then returns or prints the golfed version. There will be no newlines or tabs in the input.

This is how you golf a string. The order matters!

  1. remove spaces directly before and after punctuation: "Hey there", he said ; he ' s a cat. -> "Hey there",he said;he's a cat. The following count as punctuation: .,?!"':;()

  2. replace he/she/it is, case insensitive, with he's/she's/it's: It is unfortunate that she is not coming ever. -> It's unfortunate that she's not coming ever.

  3. words that start with capital letters in a sentence can be moved against the preceding word (omitting the space): The farmer told Fred that he should leave. -> The farmer toldFred that he should leave.

  4. trailing and leading spaces should be removed: [ ]It's raining.[ ]-> It's raining. Ignore the brackets (annoying auto-formatting).

  5. Remove repeated punctuation that is the same: ""Here''s the cake",, said Fred..! -> "Here's the cake",saidFred.!

If we were to golf the first paragraph of this challenge, the output would be:

Everybody loves golfing code.Code is written inEnglish(eh.).Therefore,everybody loves golfingEnglish!

This is code golf––or rather English golf––so shortest code in bytes wins!


Here is one all encompassing test case:

Input: " You are crazy"",, , , she said. It is unfortunate that Margaret had to say that... she is a Martian!.
Output: "You are crazy",she said.It's unfortunate thatMargaret had to say that.she's aMartian!.

Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English!

Your task is to write a program or function that takes a string as input, and then returns or prints the golfed version. There will be no newlines or tabs in the input.

This is how you golf a string. The order matters!

  1. Remove spaces directly before and after punctuation: "Hey there", he said ; he ' s a cat. -> "Hey there",he said;he's a cat. The following count as punctuation: .,?!"':;()

  2. Replace he/she/it is, case insensitive, with he's/she's/it's: It is unfortunate that she is not coming ever. -> It's unfortunate that she's not coming ever.

  3. Words that start with capital letters in a sentence can be moved against the preceding word (omitting the space): The farmer told Fred that he should leave. -> The farmer toldFred that he should leave.

  4. Trailing and leading spaces should be removed: [ ]It's raining.[ ]-> It's raining. Ignore the brackets (annoying auto-formatting).

  5. Remove repeated punctuation that is the same: ""Here''s the cake",, said Fred..! -> "Here's the cake",saidFred.!

If we were to golf the first paragraph of this challenge, the output would be:

Everybody loves golfing code.Code is written inEnglish(eh.).Therefore,everybody loves golfingEnglish!

This is code golf––or rather English golf––so shortest code in bytes wins!


Here is one all encompassing test case:

Input: " You are crazy"",, , , she said. It is unfortunate that Margaret had to say that... she is a Martian!.
Output: "You are crazy",she said.It's unfortunate thatMargaret had to say that.she's aMartian!.

deleted 1 character in body
Source Link
Daniel
  • 6.7k
  • 1
  • 21
  • 58

Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English!

Your task is to write a program or function that takes a string as input, and then returns or prints the golfed version. There will be no newlines or tabs in the input.

This is how you golf a string. The order matters!

  1. remove spaces directly before and after punctuation: "Hey there", he said ; he ' s a cat. -> "Hey there",he said;he's a cat. The following count as punctuation: .,?!"':;()

  2. replace he/she/it is, case insensitive, with he's/she's/it's: It is unfortunate that she is not coming ever. -> It's unfortunate that she's not coming ever.

  3. words that start with capital letters in a sentence can be moved against the preceding word (omitting the space): The farmer told Fred that he should leave. -> The farmer toldFred that he should leave.

  4. trailing and leading spaces should be removed: [ ]It's raining.[ ]-> It's raining. Ignore the brackets (annoying auto-formatting).

  5. Remove repeated punctuation that is the same: ""Here''s the cake",, said Fred..! -> "Here's the cake",saidFred.!

If we were to golf the first paragraph of this challenge, the output would be:

Everybody loves golfing code.Code is written inEnglish(eh.).Therefore,everybody loves golfingEnglish!

This is code golf––or rather English golf––so shortest code in bytes wins!


Here is one all encompassing test case:

Input: " You are crazy"",, , , she said. It is unfortunate that Margaret had to say that... she is a Martian!.
Output: "You are crazy",she said.It's unfortunate thatMargaret had to say that.she isshe's aMartian!.

Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English!

Your task is to write a program or function that takes a string as input, and then returns or prints the golfed version. There will be no newlines or tabs in the input.

This is how you golf a string. The order matters!

  1. remove spaces directly before and after punctuation: "Hey there", he said ; he ' s a cat. -> "Hey there",he said;he's a cat. The following count as punctuation: .,?!"':;()

  2. replace he/she/it is, case insensitive, with he's/she's/it's: It is unfortunate that she is not coming ever. -> It's unfortunate that she's not coming ever.

  3. words that start with capital letters in a sentence can be moved against the preceding word (omitting the space): The farmer told Fred that he should leave. -> The farmer toldFred that he should leave.

  4. trailing and leading spaces should be removed: [ ]It's raining.[ ]-> It's raining. Ignore the brackets (annoying auto-formatting).

  5. Remove repeated punctuation that is the same: ""Here''s the cake",, said Fred..! -> "Here's the cake",saidFred.!

If we were to golf the first paragraph of this challenge, the output would be:

Everybody loves golfing code.Code is written inEnglish(eh.).Therefore,everybody loves golfingEnglish!

This is code golf––or rather English golf––so shortest code in bytes wins!


Here is one all encompassing test case:

Input: " You are crazy"",, , , she said. It is unfortunate that Margaret had to say that... she is a Martian!.
Output: "You are crazy",she said.It's unfortunate thatMargaret had to say that.she is aMartian!.

Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English!

Your task is to write a program or function that takes a string as input, and then returns or prints the golfed version. There will be no newlines or tabs in the input.

This is how you golf a string. The order matters!

  1. remove spaces directly before and after punctuation: "Hey there", he said ; he ' s a cat. -> "Hey there",he said;he's a cat. The following count as punctuation: .,?!"':;()

  2. replace he/she/it is, case insensitive, with he's/she's/it's: It is unfortunate that she is not coming ever. -> It's unfortunate that she's not coming ever.

  3. words that start with capital letters in a sentence can be moved against the preceding word (omitting the space): The farmer told Fred that he should leave. -> The farmer toldFred that he should leave.

  4. trailing and leading spaces should be removed: [ ]It's raining.[ ]-> It's raining. Ignore the brackets (annoying auto-formatting).

  5. Remove repeated punctuation that is the same: ""Here''s the cake",, said Fred..! -> "Here's the cake",saidFred.!

If we were to golf the first paragraph of this challenge, the output would be:

Everybody loves golfing code.Code is written inEnglish(eh.).Therefore,everybody loves golfingEnglish!

This is code golf––or rather English golf––so shortest code in bytes wins!


Here is one all encompassing test case:

Input: " You are crazy"",, , , she said. It is unfortunate that Margaret had to say that... she is a Martian!.
Output: "You are crazy",she said.It's unfortunate thatMargaret had to say that.she's aMartian!.

added 283 characters in body
Source Link
Daniel
  • 6.7k
  • 1
  • 21
  • 58

Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English!

Your task is to write a program or function that takes a string as input, and then returns or prints the golfed version. There will be no newlines or tabs in the input.

This is how you golf a string. The order matters!

  1. remove spaces directly before and after punctuation: "Hey there", he said ; he ' s a cat. -> "Hey there",he said;he's a cat. The following count as punctuation: .,?!"':;()

  2. replace he/she/it is, case insensitive, with he's/she's/it's: It is unfortunate that she is not coming ever. -> It's unfortunate that she's not coming ever.

  3. words that start with capital letters in a sentence can be moved against the preceding word (omitting the space): The farmer told Fred that he should leave. -> The farmer toldFred that he should leave.

  4. trailing and leading spaces should be removed: [ ]It's raining.[ ]-> It's raining. Ignore the brackets (annoying auto-formatting).

  5. Remove repeated punctuation that is the same: ""Here''s the cake",, said Fred..! -> "Here's the cake",saidFred.!

If we were to golf the first paragraph of this challenge, the output would be:

Everybody loves golfing code.Code is written inEnglish(eh.).Therefore,everybody loves golfingEnglish!

This is code golf––or rather English golf––so shortest code in bytes wins!


Here is one all encompassing test case:

Input: " You are crazy"",, , , she said. It is unfortunate that Margaret had to say that... she is a Martian!.
Output: "You are crazy",she said.It's unfortunate thatMargaret had to say that.she is aMartian!.

Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English!

Your task is to write a program or function that takes a string as input, and then returns or prints the golfed version. There will be no newlines or tabs in the input.

This is how you golf a string. The order matters!

  1. remove spaces directly before and after punctuation: "Hey there", he said ; he ' s a cat. -> "Hey there",he said;he's a cat. The following count as punctuation: .,?!"':;()

  2. replace he/she/it is, case insensitive, with he's/she's/it's: It is unfortunate that she is not coming ever. -> It's unfortunate that she's not coming ever.

  3. words that start with capital letters in a sentence can be moved against the preceding word (omitting the space): The farmer told Fred that he should leave. -> The farmer toldFred that he should leave.

  4. trailing and leading spaces should be removed: [ ]It's raining.[ ]-> It's raining. Ignore the brackets (annoying auto-formatting).

  5. Remove repeated punctuation that is the same: ""Here''s the cake",, said Fred..! -> "Here's the cake",saidFred.!

If we were to golf the first paragraph of this challenge, the output would be:

Everybody loves golfing code.Code is written inEnglish(eh.).Therefore,everybody loves golfingEnglish!

This is code golf––or rather English golf––so shortest code in bytes wins!

Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English!

Your task is to write a program or function that takes a string as input, and then returns or prints the golfed version. There will be no newlines or tabs in the input.

This is how you golf a string. The order matters!

  1. remove spaces directly before and after punctuation: "Hey there", he said ; he ' s a cat. -> "Hey there",he said;he's a cat. The following count as punctuation: .,?!"':;()

  2. replace he/she/it is, case insensitive, with he's/she's/it's: It is unfortunate that she is not coming ever. -> It's unfortunate that she's not coming ever.

  3. words that start with capital letters in a sentence can be moved against the preceding word (omitting the space): The farmer told Fred that he should leave. -> The farmer toldFred that he should leave.

  4. trailing and leading spaces should be removed: [ ]It's raining.[ ]-> It's raining. Ignore the brackets (annoying auto-formatting).

  5. Remove repeated punctuation that is the same: ""Here''s the cake",, said Fred..! -> "Here's the cake",saidFred.!

If we were to golf the first paragraph of this challenge, the output would be:

Everybody loves golfing code.Code is written inEnglish(eh.).Therefore,everybody loves golfingEnglish!

This is code golf––or rather English golf––so shortest code in bytes wins!


Here is one all encompassing test case:

Input: " You are crazy"",, , , she said. It is unfortunate that Margaret had to say that... she is a Martian!.
Output: "You are crazy",she said.It's unfortunate thatMargaret had to say that.she is aMartian!.

"He is", "She is", and "It is" also being replaced with "He's", "She's", and "It's", respectively, conveys case-insensitivity
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading
deleted 35 characters in body
Source Link
Daniel
  • 6.7k
  • 1
  • 21
  • 58
Loading
OP said in the comments white space only meant space. Clarified.
Source Link
Riker
  • 7.9k
  • 4
  • 39
  • 73
Loading
[Edit removed during grace period]
Source Link
Daniel
  • 6.7k
  • 1
  • 21
  • 58
Loading
added 78 characters in body
Source Link
Daniel
  • 6.7k
  • 1
  • 21
  • 58
Loading
added 48 characters in body
Source Link
Daniel
  • 6.7k
  • 1
  • 21
  • 58
Loading
added 2 characters in body
Source Link
Daniel
  • 6.7k
  • 1
  • 21
  • 58
Loading
Source Link
Daniel
  • 6.7k
  • 1
  • 21
  • 58
Loading