7 kyu
Spoonerize Me
2,735 of 6,941webtechalex
Loading description...
Strings
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Python tests include
pop corn -> cop porn
... Revise thatporn
please?python new test framework is required. updated in this fork
Approved
I saw solutions use interpolated strings via
return $"{value1}{value2}";
and was wondering if that's considered more effecient or better practice than manually concatenating a string viareturn str[range] + str[range];
? I know for writing to console that you should be using interpolated strings but this is my first time seeing it being used to return a string.This should not spoil the kata, I have not provided any details on the string or values.
I think that depends on the language they have been used and persons' feelings about that subject — in Python, for example, they have approximately same efficiency, while in other languages one has more power for not many strings (5-10) while the other has it for a lot of strings (100+).
While there are only two strings to concat there is no big difference between these methods imho. Still thanks for the question ^.^
Ruby translation with fixing the issue below + upgrade to 3.0
Approved.
Expected value should be calculated before calling the user's function in Ruby, because strings are mutable and it can lead to unexpected behaviour.
Impleneted here + added Ruby 3.0
Hi Test cases for ruby are still failing when my code is working correctly.
Just tested it and it worked fine for me, remember strings in Ruby are mutable, so, if your code fails only random tests, that could be it.
COBOL translation.
approved
C translation
Approved :)
In JS: numbers are expected to be swapped too if they're the first character in the word.
The description is correct because spoonerisms are about letters in words, specifically. Random test cases contain other characters, sure, but I think the task is clear enough not to warrant an issue. If you would like a change to be made to the description, please provide a suggestion and I will consider it
Seen the description, the words should be only formed with letters. Or define clearly what is a word and what't the task in general, without talking about letters when we don' consider letters. Otherwise, the requirements of this kata aren't properly defined and that's actually an issue.
The line questioned at the top of this discussion is a layperson's definition of what a spoonerism is in the domain of language. I don't think it needs to be changed as it defines a spoonerism well enough for the requirements of the kata's tests. I have added a sentence to the task description to make it explicit that "words" in the random test cases can include numbers.
failing random test expected:<...ReoJJ6 xQYybuI6AbzUS[5]plm7Grfq> but was:<...ReoJJ6 xQYybuI6AbzUS[x]plm7Grfq> I don't understand what does it mean. Help me, please!
idk why, because I did not see your code, but for some reason in between the brackets you have an x instead of a 5 in the spoonerized string
This comment has been hidden.
You're changing more letters than you should like that.
veri veri gud and veri veri nice
Hi , when spoonerizing from pop corn I keep getting coc porn, but when I should be getting cop porn , but my code works for all other test cases.
When you say it works for all other test cases, does it work for the random test cases? It looks like you are possibly doing an additional swap that isn't needed. Check the kata description again and keep trying... ;)
This comment has been hidden.
This comment has been hidden.
Thanks I'll read the docs and see where I went wrong
it can be difficult to find documentation for a lot of python built-ins many things have some documentation as part of their definitions, you can find that by passing the object in question to
help
and yeah comparing your results should also very clearly tell you what's up, I encourage you to try that route as well (you should have an expectation of what
str.replace
would do, and you should have an understanding of what the description asks, and you get a result when actually callingstr.replace
-- so you have three ideas of the result and ideally all these three should match one another and if not then you can compare them to each other)VB Translation ready for review.
Typescript Translation ready for review.
Someone is on a roll... :D
Try to stop me =D
Coffeescript Translation ready for review.
Approved. Thanks. Not sure what's going on, I made this kata like five years ago and now loads of people are discussing and translating it! :)
Most things in life follow the Math.Sin function, as does Kata interest over time ;-)
@dfhwze keep on coming with your coffeescript translations XD ~~
It's surely everyone's favorite language anyway ;-)
Rust translation!
I have left out the digits 0–9 for the random tests as the description only mentions letters will be tested for?
Approved. Thanks. Great to have a Rust version!
This comment has been hidden.
This comment has been hidden.
I don't think this highlights a bug. I'm not that familiar with C# so I could be misreading your solution, but it looks a lot like you are making the same mistake that at least one other has made on this kata. This solution will, of course, work in some cases, but not all (I won't mention the cases it will work as I don't want to spoil it for you). Take a more careful look at your code and what it is actually doing. I'm happy to be shown wrong on this. If someone can show it is a bug I can take a look at it, but I think for now it is your code that is wrong ;)
It's not a bug, I just verified. The sample tests all have something in common that magically makes your solution work. Figure this out and you'll be able to solve this :)
Julia translation
APPROVED BY SOMEONE
This comment has been hidden.
Approved but maybe you can follow the test suite guidelines next time (
it
insidedescribe
block) -> https://deploy-preview-198--reverent-edison-2864ea.netlify.app/languages/python/authoring/#example-test-suiteJava version needs to declare a data type in the method's parameters. Suggest rewrite as follows:
(words) -> (String words)
Fixed.
Python 3 should be enabled.
In Java the method signature should read public static String spoonerize(String words)
This comment has been hidden.
This comment has been hidden.
Just looking at this again and your issue has higlighted a way in which the fixed test cases could be improved. The random test cases are showing you what is wrong with your code, but the fixed ones aren't affected by the error, which is why they pass. I will update the fixed test cases and that will give you a better hint.
@webtechalex - thanks lol I guess I was way more sleep deprived than I thought because I clearly kept misreading the instructions. Totally embarassing! Kata solved. :)
No need to be embarrased. :) Thanks for helping me improve the test cases.
One caveat for Python. The description of the kata provides a three-word example ("pack of lies" --> "lack of pies"), leading one to believe that there will be some 3-word test cases.
This changes the problem slightly, since the last word's position would be variable. However (at least in Python), the tests never try any 3-word strings. So either the testing is incomplete, or the description is somewhat misleading.
Thanks for your comment @LazyWolf. Please take another look at the description. The examples in the note at the bottom of the description are there purely to address the fact that spoonerisms CAN be more complicated than two words, but it clearly states that you will NOT have to account for these more complex forms in your code. Even so, I will edit the description to try and make this more clear. :)
Added a clarification to the beginning of the note.
Oh, my apologies! I must have been scan-reading, and totally missed that part. Sorry for the mistake.
Cheers!
No worries. Thanks for the input anyway. And thanks a lot for the C# translation! :)
Translation of this kata into Kython Pumited :)
Thanks man, but I didn't get a notification. Where do I find your translation to approve it?
This comment has been hidden.
Thanks again man, just seen it in my notifications too... What can I say? It's been a long day! :)
Thanks to you, too for your good katas.
I'm just glad that people seem to like them. I will try and come up with more soon! ;)
OMG hilarious Kata :D (laughing to tears)
My favourite:
"pop corn" => "cop porn"
;)Ranked it 7kyu
I know man, I love spoonerisms. Wasn't sure whether that particular test case might have been seen as bad taste for some, but hey, I find it funny! ;)