7 kyu
makeBackronym
2,247 of 6,523AkyunaAkish
Loading description...
Fundamentals
Strings
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 new test framework is required. updated in this fork
Approved
Good 7 kyu experience.
COBOL translation.
Approved
I have used Java Microbenchmark Harness to compare the throughput of the best voted ("Best Practices" and "Clever") solution with the throughput of a solution that does not use streams.
The result is:
If anyone is interested in the details, here is the JMH project on GitHub: https://github.com/rico-ding/backronym-micro-benchmark/
That is interesting, seems like there is some additional overhead from using a stream as opposed to simply using a loop and stringbuilder
Not a kata suggestion, though it is a good effort ^^
Improved Java version upgraded to JUnit 5, use parameterized Tests, use immutable Map for preloaded dictionary.
Approved.
Improved JavaScript version upgrade to Node v14, use
chai
for assertions, freeze preloadeddict
Approved. Ta!
weird yogic volcano
LOLRuby 3.0 should be enabled, see this to learn how to do it
Enabled in this fork
This doesn't appear to relate to OO programming, could the "object-oriented programming" tag be removed, please?
Tags were cleaned up in the meantime.
nice kata, clear explanation
I think that the test cases should not mark the code wrong for a space at the end. for example, "happy apple mark " should count.
No trailing spaces. Description updated
I have the exaclty string in return but it doesn't allow me to pass the test
I had a similar issue because my code would get each word from the dictionary then add it to a new string i was building then adding a space. the issue with this was the last word also had a space. for example, "happy apple mark " is not the same as "happy apple mark". if this is the case, you need an if statement so it doesn't add a space at the end, or you could remove the last character. either way, it can't end in a space
validation on submit: first test case is wrong
I really liked the dictionary, something interesting and cool!
This comment has been hidden.
Your try to look up lowercase letters, but the dictionary only contains uppercase letters as keys!
Just insert
acronym = acronym.toUpperCase();
and you're done!This comment has been hidden.
At least your input would be helpful. With which String have you tested that? The error message hints on an array access which fails. Check on your line which might contain an array access like myArray[i] or maybe charAt(i) and check that this works for i=1 (is your input maybe just one character long? this would be too short).
This comment has been hidden.
Try it without the added quotes. The quotes are just for providing a String literal (like in the example). Your variable 'd' is probably already a String, so you can just use it in the get method as-is. So just leave out the first line of your code there.
I don't understand why I thought I needed to do that and didn't test that -_- thanks so much!
I have tried to solve this kata in Java, and I was quite sure my solution would work. But I get a "Test passed" on the second and third test, but just a "0" with no info on what's wrong on the first one. Looking at an output via System.out.println does not show anything that would anything else than the expected solution, but I don't know how the tests are setup. Is there a way to see the expected output of the tests?
This comment has been hidden.
I unfortunately cannot see your reply, as I don't have solved the kata yet, and your reply supposedly contains a spoiler. What did you write, if you don't mind me asking?
Edit: After replying I saw your comment, and found out what the problem was.
The issue is that i forgot to check for an empty string (testFixedStrings, 6th call there), but the test just failed with a "0", no further info. It would be nice if there was some feedback on why that one fails.
Thank you for your help, AkyunaAkish!
10/10, would play eager disturbing xylophone again
Thanks !
This comment has been hidden.
The strings are not equal. Load it up in notepad, put both strings from the test cases one atop of the other, and then ctrl+a. You'll notice something's off about the backronym your method is returning.
This comment has been hidden.
I am fairly new here so I apologize if this is a simple question. Is there anyway to download a copy of the Dictinary? I like to get these working in Visual Studio and with out it I can't. I can always make my own was just hoping to save some time.
No, but there is nothing to stop you running a program that dumps it to the console. :)
Here is the dictionary that is preloaded (javascript version)-
var dict = { 'A': "awesome", 'B': 'beautiful', 'C': 'confident', 'D': 'disturbing', 'E': 'eager', 'F': 'fantastic', 'G': 'gregarious', 'H': 'hippy', 'I': 'ingestable', 'J': 'joke', 'K': 'klingon', 'L': 'literal', 'M': 'mustache', 'N': 'newtonian', 'O': 'oscillating', 'P': 'perfect', 'Q': 'queen', 'R': 'rant', 'S': 'stylish', 'T': 'turn', 'U': 'underlying', 'V': 'volcano', 'W': 'weird', 'X': 'xylophone', 'Y': 'yogic', 'Z': 'zero' };
Hi, I've added a Java translation, if you want to approve it, instructions for the approval process are here.
Thanks !
I think it would be more suited to Java if the dictionary was Character -> String or Integer -> String
I agree, Character would make more sense.
Getting a couple questions on the Java translation , could you possibly take a look ? I only know Javascript. Thanks Christian !
The initial Java solution has a redundant
import java.util.stream.*;
lurking in it which seems too much of a clue to use streams for this solution. Might be better if the user was left to work that out for themselves.Added a C# translation.
Thanks !
I tried the C# version of this, and I'm repeatedly getting an exception thrown with every one of the calls saying that the key is not found. I copied my code into Visual Studio with the dictionary being a private variable in my test class, and it ran perfectly.
I have a feeling there's a disconnect and that dictionary needs to be made static on a class so we're able to access it from our test code.
Make sure your key is an upper case char as shown in the starting code. e.g.
dict['A'] = "awesome"
butdict['a']
will fail. This matches the Javascript problem, in whichdict["A"] = "awesome"
butdict["a"] = undefined
.Excellent. Thanks. Kind of an odd problem, especially with it hidden away like that.
Translations submitted on this one too, if you want to approve them :)
As usual, let me know if you may be interested in expanding the test cases in JS; I added 3 edge test on my own version, plus the usual bunch of random testing :)
Definitely open to more test cases , thanks !
New tests implemented (as usual, feel free to do some test run and tell me if you think I can improve anything) and kata greenlit :)
While at it, could I ask you about the translations for this kata? Just not sure if you were notified :)
Approved the translations , didn't notice that you translated them before , thanks !
Also have you had a chance to look at my makeAcronym beta yet?
I edited the description and am translating in this exact moment :D
Can I go ahead and add random tests already for the JS version?
Go ahead , I appreciate the help
And done: sorry for the delay, but while I got it translated relatively fast, I had connection issues while addding random test cases to the JS version.
I changed your code as default solution (and, please, do indent your code :D!), as it could not deal with some edge case (like strings with BOTH numbers and alphabetical numbers); as usual, feel free to do a test run with it :)
Sorry about that , wrote it somewhere else then copied it in and forgot to indent :) Thanks for the help !
Seeing your sincere contrition, you are fully pardoned ;)
And as a token of goodwill, you kata is also fully greenlit :)
Thanks ;)
There are a couple of questions on my makeAcronym kata in the discourses section that I don't really have the answers to because they seem to be related to the tests you implemented. If you have a chance would you be willing to check those ?
Replied, fixed a bit of small things and tested it all again: thanks for your warning :)
Thanks for the help ! I know it's not really your responsibilty , much appreciated :)
Oh, don't even mention it :)
And actually I think that it is mostly my responsibility to take care of the code I wrote in another codewarrior's kata: the merit of it is certainly all yours, while the fault for any eventual problem in the part I have translated surely rests on my shoulders.
In case any other user has issues, feel free to contact me again or to address them to directly reply to a comment of mine, so that I can be notified :)
Sounds good , thank you !
Added a couple default test cases and put the dictionary in the preloaded section. Thanks for the feedback !
You could move the dictionary into Preloaded section.
If you like, you could put the dictionary into the "preloaded" section, and just tell us what the variable is called. Either that, or make it only take up a single line, so we don't have to scroll past it.
Lacks default test cases.
I can see there are two Example Test Cases, so this issue might be resolved?
I added default cases after seeing Unihedron's comment. Issue is resolved.