Skip to main content
Commonmark migration
Source Link

In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.

Your task, if you wish to accept it, is to write a program that flips the last two letters of each word in a given string (so the word Thansk turns into Thanks). A word is a sequence of two or more letters in the English alphabet delimited by a single space.

  • The string / list of characters you receive as input is guaranteed to only contain alphabetic characters and spaces (ASCII [97 - 122], [65 - 90] and 32).

  • You can take input and provide output through any standard method, in any programming language, while taking note that these loopholes are forbidden by default.

  • The output may have one trailing space and / or one trailing newline.

  • The input will always contain words only (and the corresponding whitespace) and will consist of at least one word.

This is code-golf, so the shortest submission (scored in bytes), in each language wins!

###Test cases

Test cases

Note that the strings are surrounded with quotes for readability.

Input -> Output

"Thansk"                                 -> "Thanks"
"Youer welcoem"                          -> "Youre welcome"
"This is an apple"                       -> "Thsi si na appel"
"Flippign Lettesr Aroudn"                -> "Flipping Letters Around"
"tHe oDd chALlEneg wiht swappde lettesR" -> "teH odD chALlEnge with swapped letteRs"

Or, for test suite convenience, here are the inputs and their corresponding outputs separately:

Thansk
Youer welcoem
This is an apple
Flippign Lettesr Aroudn
tHe oDd chALlEneg wiht swappde lettesR
Thanks
Youre welcome
Thsi si na appel
Flipping Letters Around
teH odD chALlEnge with swapped letteRs

Thanks to DJMcMayhem for the title. This was originally a CMC.

In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.

Your task, if you wish to accept it, is to write a program that flips the last two letters of each word in a given string (so the word Thansk turns into Thanks). A word is a sequence of two or more letters in the English alphabet delimited by a single space.

  • The string / list of characters you receive as input is guaranteed to only contain alphabetic characters and spaces (ASCII [97 - 122], [65 - 90] and 32).

  • You can take input and provide output through any standard method, in any programming language, while taking note that these loopholes are forbidden by default.

  • The output may have one trailing space and / or one trailing newline.

  • The input will always contain words only (and the corresponding whitespace) and will consist of at least one word.

This is code-golf, so the shortest submission (scored in bytes), in each language wins!

###Test cases

Note that the strings are surrounded with quotes for readability.

Input -> Output

"Thansk"                                 -> "Thanks"
"Youer welcoem"                          -> "Youre welcome"
"This is an apple"                       -> "Thsi si na appel"
"Flippign Lettesr Aroudn"                -> "Flipping Letters Around"
"tHe oDd chALlEneg wiht swappde lettesR" -> "teH odD chALlEnge with swapped letteRs"

Or, for test suite convenience, here are the inputs and their corresponding outputs separately:

Thansk
Youer welcoem
This is an apple
Flippign Lettesr Aroudn
tHe oDd chALlEneg wiht swappde lettesR
Thanks
Youre welcome
Thsi si na appel
Flipping Letters Around
teH odD chALlEnge with swapped letteRs

Thanks to DJMcMayhem for the title. This was originally a CMC.

In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.

Your task, if you wish to accept it, is to write a program that flips the last two letters of each word in a given string (so the word Thansk turns into Thanks). A word is a sequence of two or more letters in the English alphabet delimited by a single space.

  • The string / list of characters you receive as input is guaranteed to only contain alphabetic characters and spaces (ASCII [97 - 122], [65 - 90] and 32).

  • You can take input and provide output through any standard method, in any programming language, while taking note that these loopholes are forbidden by default.

  • The output may have one trailing space and / or one trailing newline.

  • The input will always contain words only (and the corresponding whitespace) and will consist of at least one word.

This is code-golf, so the shortest submission (scored in bytes), in each language wins!

Test cases

Note that the strings are surrounded with quotes for readability.

Input -> Output

"Thansk"                                 -> "Thanks"
"Youer welcoem"                          -> "Youre welcome"
"This is an apple"                       -> "Thsi si na appel"
"Flippign Lettesr Aroudn"                -> "Flipping Letters Around"
"tHe oDd chALlEneg wiht swappde lettesR" -> "teH odD chALlEnge with swapped letteRs"

Or, for test suite convenience, here are the inputs and their corresponding outputs separately:

Thansk
Youer welcoem
This is an apple
Flippign Lettesr Aroudn
tHe oDd chALlEneg wiht swappde lettesR
Thanks
Youre welcome
Thsi si na appel
Flipping Letters Around
teH odD chALlEnge with swapped letteRs

Thanks to DJMcMayhem for the title. This was originally a CMC.

edited body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.

Your task, if you wish to accept it, is to write a program that flips the last two letters of each word in a given string (so the word Thansk turns into Thanks). A word is a sequence of two or more letters in the English alphabet delimited by a single space.

  • The string / list of characters you receive as input is guaranteed to only contain alphabetic characters and spaces (ASCII [97 - 122], [65 - 90] and 32).

  • You can take input and provide output through any defaultstandard method, in any programming language, while taking note that these loopholes are forbidden myby default.

  • The output may have one trailing space and / or one trailing newline.

  • The input will always contain words only (and the corresponding whitespace) and will consist of at least one word.

This is code-golf, so the shortest submission (scored in bytes), in each language wins!

###Test cases

Note that the strings are surrounded with quotes for readability.

Input -> Output

"Thansk"                                 -> "Thanks"
"Youer welcoem"                          -> "Youre welcome"
"This is an apple"                       -> "Thsi si na appel"
"Flippign Lettesr Aroudn"                -> "Flipping Letters Around"
"tHe oDd chALlEneg wiht swappde lettesR" -> "teH odD chALlEnge with swapped letteRs"

Or, for test suite convenience, here are the inputs and their corresponding outputs separately:

Thansk
Youer welcoem
This is an apple
Flippign Lettesr Aroudn
tHe oDd chALlEneg wiht swappde lettesR
Thanks
Youre welcome
Thsi si na appel
Flipping Letters Around
teH odD chALlEnge with swapped letteRs

Thanks to DJMcMayhem for the title. This was originally a CMC.

In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.

Your task, if you wish to accept it, is to write a program that flips the last two letters of each word in a given string (so the word Thansk turns into Thanks). A word is a sequence of two or more letters in the English alphabet delimited by a single space.

  • The string / list of characters you receive as input is guaranteed to only contain alphabetic characters and spaces (ASCII [97 - 122], [65 - 90] and 32).

  • You can take input and provide output through any default method, in any programming language, while taking note that these loopholes are forbidden my default.

  • The output may have one trailing space and / or one trailing newline.

  • The input will always contain words only (and the corresponding whitespace) and will consist of at least one word.

This is code-golf, so the shortest submission (scored in bytes), in each language wins!

###Test cases

Note that the strings are surrounded with quotes for readability.

Input -> Output

"Thansk"                                 -> "Thanks"
"Youer welcoem"                          -> "Youre welcome"
"This is an apple"                       -> "Thsi si na appel"
"Flippign Lettesr Aroudn"                -> "Flipping Letters Around"
"tHe oDd chALlEneg wiht swappde lettesR" -> "teH odD chALlEnge with swapped letteRs"

Or, for test suite convenience, here are the inputs and their corresponding outputs separately:

Thansk
Youer welcoem
This is an apple
Flippign Lettesr Aroudn
tHe oDd chALlEneg wiht swappde lettesR
Thanks
Youre welcome
Thsi si na appel
Flipping Letters Around
teH odD chALlEnge with swapped letteRs

Thanks to DJMcMayhem for the title. This was originally a CMC.

In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.

Your task, if you wish to accept it, is to write a program that flips the last two letters of each word in a given string (so the word Thansk turns into Thanks). A word is a sequence of two or more letters in the English alphabet delimited by a single space.

  • The string / list of characters you receive as input is guaranteed to only contain alphabetic characters and spaces (ASCII [97 - 122], [65 - 90] and 32).

  • You can take input and provide output through any standard method, in any programming language, while taking note that these loopholes are forbidden by default.

  • The output may have one trailing space and / or one trailing newline.

  • The input will always contain words only (and the corresponding whitespace) and will consist of at least one word.

This is code-golf, so the shortest submission (scored in bytes), in each language wins!

###Test cases

Note that the strings are surrounded with quotes for readability.

Input -> Output

"Thansk"                                 -> "Thanks"
"Youer welcoem"                          -> "Youre welcome"
"This is an apple"                       -> "Thsi si na appel"
"Flippign Lettesr Aroudn"                -> "Flipping Letters Around"
"tHe oDd chALlEneg wiht swappde lettesR" -> "teH odD chALlEnge with swapped letteRs"

Or, for test suite convenience, here are the inputs and their corresponding outputs separately:

Thansk
Youer welcoem
This is an apple
Flippign Lettesr Aroudn
tHe oDd chALlEneg wiht swappde lettesR
Thanks
Youre welcome
Thsi si na appel
Flipping Letters Around
teH odD chALlEnge with swapped letteRs

Thanks to DJMcMayhem for the title. This was originally a CMC.

added 9 characters in body
Source Link
Steadybox
  • 16.5k
  • 5
  • 41
  • 84

In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.

Your task, if you wish to accept it, is to write a program that flips the last two letters of each word in a given string (so the word Thansk turns into Thanks). A word is a sequence of two or more letters in the English alphabet delimited by a single space.

  • The string / list of characters you receive as input is guaranteed to only contain alphabetic characters and spaces (ASCII [97 - 122], [65 - 90] and 32).

  • You can take input and provide output through any default method, in any programming language, while taking note that these loopholes are forbidden my default.

  • The output may have one trailing space and / or one trailing newline.

  • The input will always contain words only (and the corresponding whitespace) and will consist of at least one word.

This is code-golf, so the shortest submission (scored in bytes), in each language wins!

###Test cases

Note that the strings are surrounded with quotes for readability.

Input -> Output

"Thansk"                                 -> "Thanks"
"Youer welcoem"                          -> "Youre welcome"
"This is an apple"                       -> "Thsi si na appel"
"Flippign Lettesr Aroudn"                -> "Flipping Letters Around"
"tHe oDd chALlEneg wiht swappde lettesR" -> "teH odD chALlEnge with swapped letteRs"

Or, for test suite convenience, here are the inputs and their corresponding outputs separately:

Thansk
Youer welcoem
This is an apple
Flippign Lettesr Aroudn
tHe oDd chALlEneg wiht swappde lettesR
Thanks
Youre welcome
Thsi si na appel
Flipping Letters Around
teH odD chALlEnge with swapped letteRs

Thanks to DJMcMayhem for the title. This was originally a CMC.

In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.

Your task, if you wish to accept it, is to write a program that flips the last two letters of each word in a given string (so the word Thansk turns into Thanks). A word is a sequence of two or more letters in the English alphabet delimited by a single space.

  • The string / list of characters you receive as input is guaranteed to only contain alphabetic characters and spaces (ASCII [97 - 122], [65 - 90] and 32).

  • You can take input and provide output through any default method, in any programming language, while taking note that these loopholes are forbidden my default.

  • The output may have one trailing space and / or one trailing newline.

  • The input will always contain words only (and the corresponding whitespace) and will consist of at least one word.

This is code-golf, so the shortest submission (scored in bytes), in each wins!

###Test cases

Note that the strings are surrounded with quotes for readability.

Input -> Output

"Thansk"                                 -> "Thanks"
"Youer welcoem"                          -> "Youre welcome"
"This is an apple"                       -> "Thsi si na appel"
"Flippign Lettesr Aroudn"                -> "Flipping Letters Around"
"tHe oDd chALlEneg wiht swappde lettesR" -> "teH odD chALlEnge with swapped letteRs"

Or, for test suite convenience, here are the inputs and their corresponding outputs separately:

Thansk
Youer welcoem
This is an apple
Flippign Lettesr Aroudn
tHe oDd chALlEneg wiht swappde lettesR
Thanks
Youre welcome
Thsi si na appel
Flipping Letters Around
teH odD chALlEnge with swapped letteRs

Thanks to DJMcMayhem for the title. This was originally a CMC.

In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.

Your task, if you wish to accept it, is to write a program that flips the last two letters of each word in a given string (so the word Thansk turns into Thanks). A word is a sequence of two or more letters in the English alphabet delimited by a single space.

  • The string / list of characters you receive as input is guaranteed to only contain alphabetic characters and spaces (ASCII [97 - 122], [65 - 90] and 32).

  • You can take input and provide output through any default method, in any programming language, while taking note that these loopholes are forbidden my default.

  • The output may have one trailing space and / or one trailing newline.

  • The input will always contain words only (and the corresponding whitespace) and will consist of at least one word.

This is code-golf, so the shortest submission (scored in bytes), in each language wins!

###Test cases

Note that the strings are surrounded with quotes for readability.

Input -> Output

"Thansk"                                 -> "Thanks"
"Youer welcoem"                          -> "Youre welcome"
"This is an apple"                       -> "Thsi si na appel"
"Flippign Lettesr Aroudn"                -> "Flipping Letters Around"
"tHe oDd chALlEneg wiht swappde lettesR" -> "teH odD chALlEnge with swapped letteRs"

Or, for test suite convenience, here are the inputs and their corresponding outputs separately:

Thansk
Youer welcoem
This is an apple
Flippign Lettesr Aroudn
tHe oDd chALlEneg wiht swappde lettesR
Thanks
Youre welcome
Thsi si na appel
Flipping Letters Around
teH odD chALlEnge with swapped letteRs

Thanks to DJMcMayhem for the title. This was originally a CMC.

Tweeted twitter.com/StackCodeGolf/status/946128470798675968
added 6 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading
added 69 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading
added 51 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading
added 15 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading
added 8 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading
deleted 81 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading
added 4 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading
Post Undeleted by Mr. Xcoder
Post Deleted by Mr. Xcoder
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading