7 kyu

Spoonerize Me

2,478 of 6,972webtechalex

Description:

A spoonerism is a spoken phrase in which the first letters of two of the words are swapped around, often with amusing results.

In its most basic form a spoonerism is a two word phrase in which only the first letters of each word are swapped:

"not picking" --> "pot nicking"

Your task is to create a function that takes a string of two words, separated by a space: words and returns a spoonerism of those words in a string, as in the above example. A "word" in the context of this kata can contain any of the letters A through Z in upper or lower case, and the numbers 0 to 9. Though spoonerisms are about letters in words in the domain of written and spoken language, numbers are included in the inputs for the random test cases and they require no special treatment.

NOTE: All input strings will contain only two words. Spoonerisms can be more complex. For example, three-word phrases in which the first letters of the first and last words are swapped: "pack of lies" --> "lack of pies" or more than one letter from a word is swapped: "flat battery --> "bat flattery" You are NOT expected to account for these, or any other nuances involved in spoonerisms.

Once you have completed this kata, a slightly more challenging take on the idea can be found here: http://www.codewars.com/kata/56dbed3a13c2f61ae3000bcd

Strings
Algorithms

More By Author:

Check out these other kata created by webtechalex

Stats:

CreatedFeb 8, 2016
PublishedMar 6, 2016
Warriors Trained10165
Total Skips141
Total Code Submissions14383
Total Times Completed6972
JavaScript Completions2742
Python Completions2478
C# Completions476
Java Completions919
Ruby Completions200
Julia Completions21
Rust Completions108
CoffeeScript Completions14
TypeScript Completions151
VB Completions68
R Completions23
C Completions66
COBOL Completions6
Total Stars87
% of votes with a positive feedback rating93% of 894
Total "Very Satisfied" Votes779
Total "Somewhat Satisfied" Votes105
Total "Not Satisfied" Votes10
Ad
Contributors
  • webtechalex Avatar
  • natan Avatar
  • raulbc777 Avatar
  • LazyWolf Avatar
  • michalmela Avatar
  • nbeck Avatar
  • imjasonmiller Avatar
  • JohanWiltink Avatar
  • hobovsky Avatar
  • stellartux Avatar
  • trashy_incel Avatar
  • akar-0 Avatar
  • dfhwze Avatar
  • blongworth Avatar
  • 4500zenja1 Avatar
  • saudiGuy Avatar
Ad