5 kyu
Phone Directory
241 of 6,926g964
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.
Bad kata, didn't like it.
Very nice kata to practice with.
Neither description, nor provided examples do not specify, if the commas should be removed form the address. Also not specified the behavior for undersocre. Had to guess on those two. Failed tests do not provide enough information, because output is truncated in error messages.
Hi Everyone!
I would use NPos function in my code but the compiler returns with "unknown identifier"-message. Pos function is working well. Strange.... (Used language: Pascal)
I found the reason meanwhile. I have to include StrUtils unit...
This wasn't that bad without regex (in Python).
python new test framework is required. updated in this fork
Approved.
This comment has been hidden.
Which language?
PHP
?
I don't understand why only 8 solutions appear on the tab with the solutions. Based on the extent of the discussion, many more people should have solved the kata.
I suggest adding these test cases: One or more of the address components (name, phone, address) is missing. The phone number does not match the format mask, for example, the "+" sign is missing.
testcases are broken for js correct answer cant be readen
no description for output address format (like trim spaces)
JS
mocha + chai
framework should be usedRuby 3.0 should be enabled
This comment has been hidden.
Finding all the ways the output needs to be scrubbed is disappointing. I don't mind doing this kind of problem, but if the requirements have to be reversed engineered by running attempts on a remote machine is beyond frustrating. Kind of wish there were tags or labels for "incomplete requirements". I don't mean to be too harsh, but spending time on something clunky like this makes need "to walk away".
I had to tinker, the task with strings is interesting, but there are nuances. I tried to find a solution without using regular expressions, maybe that's why it turned out hard. The condition is not quite complete, (underscores, double spaces for example). However, the task describes a completely working situation, when you need to take into account all the nuances, even if for some reason they are not displayed in the tests.
Kind of an interesting kata but misses details in the description, like which non-alpha-numeric characters we HAVE to keep, and not to keep doubles spaces in the addresses.
Solution could go in different ways according to what is needed exactly, and since we can't directly ask the author, we shouldn't have to guess what is expected from us by perusing several random cases.
My code passes each test but it fails in only one random test. For "8-421-674-8974", it says that my function returns "Too many people" bu actually it is not...
My functions output should be "Phone => 8-421-674-8974, Name => Anastasia, Address => 4 Via Quirinal Roma" like in my local. And also expected result for only this case is "Phone => 8-421-674-8974, Name => Elizabeth Corber, Address => Via Papa Roma" which is false...
You've most likely misread the test output. I suggest printing out the input and your result so that you can see for yourself how your function behaved. Also make sure that the failed test isn't the one above/below the one you're looking at or something like that.
(also, it probably fails on "only one" test because it stops upon failing? there would probably have been more)
I replicate the test output and it passed the same test but when i try to attempt, it fails the same test again. I checked the string again and expected result is false like i mentioned above. Name and address of the expected result is not true. I mean expected name is not related to that number and address is different than what it should be. I really stuck, i can share my code if you want. Maybe i couldn't see the problem :)
You should share the test case, because without that then your whole description of the problem is: "does not pass" and nobody can agree or disagree with that
and again, make sure you're not mixing up your output with the test result of the previous/next test. you could be looking at the output of a test that passed instead of the one that failed.
when you run it locally you might also be running a different test case than the one you failed. same thing really. find out what the failing test case was.
looking at the python tests (I assume the go ones uses the same text), the entry for Anastasia is:
"<Anastasia> +48-421-674-8974 Via Quirinal Roma\n <P Salinger> Main Street, +1-098-512-2222, Denver\n"
so when you say that
then no, it shouldn't be. that doesn't match the entry for Anastasia.
so when you run your code and find that your function gives that result, you can easily manually look at the test input and see that this was wrong.
I've just taught myself enough Go to write a working solution and natan is correct; this is not a kata issue.
Maybe i could not explain myself clearly. Sorry for that. I am totally with you on this but what i mean is that there is no Elizabeth Corber in the phonebook string. And my code is not giving Too many users error in my local. The problem is when i upload the code here, random kata test fails but like i said, there is not Elizabet Corber and giving the same number, even if it is not giving the same output on my local (i aggree with you that this specific case is wrong in my code but my point is different.) Again for number 8-421-674-8974, Anastasia is not the actual person and i agree with you that my output is wrong but there is no related user for this number in this kata. This phone number is not exist but this kata is giving "Phone => 8-421-674-8974, Name => Elizabeth Corber, Address => Via Papa Roma" output for this number which is not.
There definitely is a related user for that number in the kata's full test suite, and it is definitely Elizabeth Corber. Remember that the example tests are just examples. The full test suite uses different information.
Oh, i didn't know that. Thats why i was trying to explain it to you. I thougt full test uses the same info but I was wrong. My bad, so sorry for that. :)
You could have printed the input.
Its my bad, i solved the kata. It was my code that was not work properly, not the kata. :)
Should be 4th kyu since the efford is huge to fix all the data sanitation cases for all tests. The time spent for the points received is not in a good relation. Also it should be categorized as Regex.
You don't need to use regex to solve this kata and changing the rank of a kata is not possible, so this can not be an issue. Also, if this kata would be published today, with the new standards, it would be at most 6 kyu...
Well, paging down a couple of screens there is not one person not heavily using Regex. Yes, most things can be solved without Regex by going huge detours with regular code. Still this is a typical Regex challenge (as proven by all solutions provided) and as such it should be indicated.
I was speaking about myself :D I didn't use regex (but I solved it in python and you probably solved it in Ruby, so you can't see my solution).
Same here, didn't use regex at all in Python.
And since ranking is shared by all the languages, you have to see
5kyu
as a sort of average.In Python, it required a bit of thinking, but I could see it be easily a
6kyu
.The problem description is lacking some things: the double-space behavior (i.e. consecutive whitespace isn't allowed for the address), a list of "junk" characters (which from the attempts I guess they're
?$/,;*:
, although some could be missing), that_
should be replaced with a single space, etc.I don't feel that as an issue; the best thing to do would be a complete explanation... or to give the code:-) Don't you think that a bit of work is needed for a 5 kyu.
I disagree: the difficulty of the problem does not lie in discovering these rules, but rather implementing a solution to filter them. I had a solution that followed every rule showed in the description and sample problems, yet it didn't pass simply because some new rules were introduced in the hidden tests. I then painfully spent some minutes figuring out what hidden rules the hidden tests were expecting, which imo took some fun from the problem, which is quite nice.
I agree. The kata lacks specifications. For example we don't know what should be done with non-alpha-numeric characters, it's not enough with removing them (and this is not even in the description). There is a margin between giving the code and asking the user to play charades from the random tests results to understand what must be done: The description should clearly state all requirements the user is expected to fulfill to complete the kata.
Idiot kata. I did everything, but couldn't delete fucking double spaces (" "), because: unmap_chunk(): invalid pointer UndefinedBehaviorSanitizer:DEADLYSIGNAL ==1==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f33fbf79a10 bp 0x7ffdd6a25730 sp 0x7ffdd6a254e0 T1) ==1==The signal is caused by a READ memory access. ==1==Hint: address points to the zero page. ==1==WARNING: invalid path to external symbolizer! ==1==WARNING: Failed to use and restart external symbolizer! #0 0x7f33fbf79a0f (/lib/x86_64-linux-gnu/libc.so.6+0x40a0f) #1 0x7f33fbfc2966 (/lib/x86_64-linux-gnu/libc.so.6+0x89966) #2 0x7f33fbfc99d9 (/lib/x86_64-linux-gnu/libc.so.6+0x909d9) #3 0x7f33fbfd0fbb (/lib/x86_64-linux-gnu/libc.so.6+0x97fbb) #4 0x42d461 (/workspace/test+0x42d461) #5 0x430121 (/workspace/test+0x430121) #6 0x42e52e (/workspace/test+0x42e52e) #7 0x42df5d (/workspace/test+0x42df5d) #8 0x42dc4b (/workspace/test+0x42dc4b) #9 0x433b85 (/workspace/test+0x433b85) #10 0x42c09d (/workspace/test+0x42c09d) #11 0x7f33fbf5abf6 (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6) #12 0x407b09 (/workspace/test+0x407b09)
UndefinedBehaviorSanitizer can not provide additional info. ==1==ABORTING
It means fuck you, you can't delete it.
If someone tell me why it can be, I will be very grateful. I could replace double spaces on "Z", "V", "A", and I think on any symbol or string, but not on singly space.
rust memory issue, in all my years, just wow
Strings are fun! 0 is a number, empty array is still array, invisible string is still a string! Comparing to custom roman numerals decoding or getting rule30 1st time, this was a breeze. Thx
For the string:
what is the address?
This comment has been hidden.
No issue in sight.
This would've been crazy to solve without looking at the inputs being supplied.
Can't complete this, it's not removing the white spaces from the address in the test even though it works in my IDE...
let filter9 = filter8.replace(/(\s\s)/, ' ');
This comment has been hidden.
I had nervous breakdown solving this task. It should be symplified or descibed more detaily. In the description is not said that there can be some extra symbols to delete, like "*" or ";", also its not mentioned that we need to correct the adress output deleting double spacing. If syplified it can be good, practical with higher percentage of successful solutions.
Python I had a mistake: Expected : Error => Too many people: 8-421-674-8974 to equal : Phone => 8-421-674-8974, Name => Elizabeth Corber, Address => Via Papa Roma
but it's OK when I submit it many times,WHY???
This comment has been hidden.
I think you're right,I will try next time,thx
i think its not actually, but/// 8-421-674-8974 is not 48-421-674-8974
It would be nice to have "Regular Expressions" tag added here
I solved it without them, but I really wish I didn't...
I was a little confused with how the address looks. For me, it was unclear and unspecified, and I could not complete kata because of this. It would be much better if the author extend description with address specification, like name and number has. Yeah I know there are tests, but still it felt like reverse engineering and guesing.
golang have a problem with res: Expected : Error => Too many people: 8-421-674-8974 to equal : Phone => 8-421-674-8974, Name => Elizabeth Corber, Address => Via Papa Roma
but in my ouwn test its ok
I have the same problem. Have you solved it
I am not expecting this to be a real issue but just in case. I have repeated fail the Attempt over three problems 2 of which I think may actually be issues so airing in the side of caution here's the problem
Recieved Address => Solomn[]Street Now to be clear I had this problem before with 2 others but I solved them by just giving them the necessary space. Its this one, I think is being bugging. Now it may be that I have accidently filtered out a comma that removed an essential space that led to this because none of my other attempts have this problem, and I have rigiourly been testing this but the problem seems to somehow have a correlation not with .filter{} but with trim(). Which is a problem that Ineither understand becuase trimStart nor, trimEnd seems to be working for me or works on this. Anyhow onto my second issue:
When reporting an issue, please, mention the language you're talking about. About 1. It seems the expected has a single space between Solomn and Street and the other has none, please read this: https://docs.codewars.com/training/troubleshooting/#post-discourse and use markdown formatting if that's not the case.
They are specific enough: look at the top of the page to see how many people passed the kata. Sorry but your code has at least one flaw:-( Cheers.
It was a great kata, Thanks for sharing it!
Thanks!
This kata is modelled after real life experiences as a developer (which is an interesting take), but since the only way to get the real specifications is try and error, it's quite frustrating. I didn't even get it completly right even though the solution was accepted, because I got lucky (or unlucky) with the test cases, which I found out after it was not accepted anymore after cleanup.
I once had a quite similar task at my job and it was not fun, but that was kind of ok, because I got paid to do it. In my opionion codewars katas should be fun to solve, not frustrating.
The idea of this kata in general was interesting. Would have been great if it was fully specified.
I couldn't agree more
Amazing Kata)
Thanks!
This comment has been hidden.
Sorry for this inconvenience but that problem frequently occurs in real life...
A real life problem! Congrats g964.
Thanks!
I had an issue with the word "Mount" sometimes being expect on the address and sometimes not. Weird. I had to keep pressing the "Submit" button until it actually went OK.
Reminds me very much of real life work. Incomplete descriptions. Testing and adjusting by running it live. To all those complaining: Yes, it is frustrating. But also: This is a glimpse into paid work in the industry...
True, so far this is one of the closest katas to real work tasks I've encountered.
Bad description, solution only achievable upon running the code and fixing it based on the errors that pop up.
This comment has been hidden.
Also, sorry that the code looks so bad - didn't realize all my indents would disappear once you post the comment...
Issue in Julia: Expected: "Error => Too many people: 8-421-674-8974" Occurred: "Phone => 8-421-674-8974, Name => Elizabeth Corber, Address => Via Papa Roma"
I corrected an unfortunate typo. Lots of thanks!
I'm not understanding why this isn't working. I've read the space-related comments. Maybe there's white-space to clean that I'm not seeing.
I get (C++) Expected: Phone => 48-421-674-8974, Name => Anastasia, Address => Via Quirinal Roma Actual: Phone => 48-421-674-8974, Name => Anastasia, Address => Via Quirinal Roma
Looks good to me??
I did the modification to replace spaces with asterisks and saw no double spaces or trailing spaces.
I had a similar problem and I realized there were double spaces appearing when assembling the final string. I coul solve it by filtering them once more before returning result.
Don't you have two spaces between "...Rd." and "NY-..."?
Hi guys
Im trying do do this Kata in swift but dont know how to use regex in swift? with options: regularexpression or range. And how to compare 2 parts after i use split with "/n" ?
I cannot see solutions because dont have enough kyu
The description for this kata could do with expanding.
It does state that everything other than the phone number and name may contain erroneous non-alphanumeric characters but it doesn't state which characters are erroneous nor does it state that erroneous characters in the address should be replaced with a space.
The example does cover it but it would be helpful if the requirements were more clearly defined.
I agree. An expansion on the address part would is lacking. I was not able to complete this kata due to this.
What is nb supposed to be? i do not understand what it means in the description when it references nb. Is this meant to be the input, num?
"It can happen that, for a few phone numbers, there are many people for a phone number -say nb- "
nb is never referred to until this point
Yes. But only when there are many people with the same number or when it's not in the phone book. No idea why an alias was used there.
I slightly modified the description.
The descriptions is incomplete and contradictory. The dot
.
is a non-alpha-numeric symbol, but it does not clutter a line, it is a part of an address (according to the tests). The underscore_
not just adds more garbage, but replaces a single space (according to the tests). It would be good to mention these corner cases.Not just corner cases, it looks like the author decided to define the question by his test cases. What happens if something outside of the test case scope is entered or desired (like possibly preventing double quotes in an address, or removing "th" from a street number like 7th -> 7). These points really should have been defined in the problem description. The ambiguity is really just turning this problem into a scavenger hunt rather than an attempt at coding.
If I want to hunt for problem/product requirements, I'll just go into work tomorrow where I do it everyday. Why waste my time with this problem.
I seem to be having a problem. But I'm not sure whether it's an issue with my own code or whether there's a problem with the kata. All the sample as well as the random tests were successful. However, in both the sample and random tests I get this
TypeError: Can't read property '0' of null
. And the thing is, with everyAttempt
, the number or errors keep changing. From 8 errors, to 5 errors or 6 errors or 2 errors.There doesn't seem to be a problem with the code though. I copied the entire thing, both the function and the input and tested them in the console. Didn't get the TypeError.
I've tried my solution again and it passed. You didn't say, but I guess that's in javascript. Are you using
match
?Yes, I'm using
match
. And btw I checked once again. The sample tests run fine now. But the problem persists when testing for random tests withAttempt
.match
not always returns an array, check that.Ah, is that so. I didn't think that would be the case. I'll look into it. Thanks
Just asking out of curiosity, which language did you solve the kata in?
Javascript.
This comment has been hidden.
No problem, and you can (almost always) use
console.log
to print the input and check what it was.Yeah I'd stay away from this. The solution is pretty simple but the tests are brittle which is very frustrating.
Which? Why? 125 guys passed the C++ kata.
No idea why. It refuses to even give me anything to work with. It just says "tests failed". I checked the program output on my machine and it seems to output things correct.
Well, it's a code issue alright. Post it in spoilers. Also make sure you're not mutating the input, it can really mess things up.
This comment has been hidden.
Instructions are unclear in stating what non-alpha-numeric characters are acceptable as part of the address (i.e. '.' and '-'), which ones need to be replaced (i.e. '_'), and which ones should be deleted (e.g. ';', '$', extra whitespace, etc.).
If the intention is to look at the examples to determine how non-alpha-numeric characters should be dealt with for the address, the description should state so explicitly in place of the current ambiguous statement
parts of lines are cluttered with non-alpha-numeric characters (except inside phone number and name)
.Address form is not specific in rules. Please, rework a bit instructions. Underscores should be replaced with space, forbidden ";", "&" and etc.
The reason why you should never do
str == str
in solutions is: The answer:Phone => 1-908-512-2222, Name => Peter O'Brien, Address => High Street CC-47209
My answer:Phone => 1-908-512-2222, Name => Peter O'Brien, Address => High Street CC-47209
The difference is one space. Stop comparing
str == str
in solutions where there is no reason for it. This kata could have it's solutions as adict
which is not just more readable but this is what we would do in real life:There is no reason here for using strings like this.
i absolutly agree with you , in fact they should accept all forms of data types for a more realistic and complete training ...
I'm having issues with the TS fixed tests when I "attempt". It's telling me that a particular entry should be erring for "too many people", but I've tested that in my sample tests and it's passed. I think the fixed test's expected answers might need to be reviewed?
Please when you post an issue give the input, your ouput, what the failing test reports. Write all these things between backticks so it is easily readable. Besides that I am sure there are no errors in the tests. JS and TS have the same fixed tests and 28 people passed the TS kata, 482 the JS one. Cheers.
I had a lot of fun with this kata. Thank you for this!
Thanks!
This comment has been hidden.
ps. random tests pass
This comment has been hidden.
Nothing broken. Did you read this in the description:
s = "/+1-541-754-3010 156 Alphand_St. \n 133, Green, Rd. NY-56423 ;+1-541-914-3010!\n"
phone(s, "1-541-754-3010") should return "Phone => 1-541-754-3010, Name => J Steeve, Address => 156 Alphand St."
?
what ?
Fixed_Phone Expected: equal to Phone => 1-541-754-3010, Name => J Steeve, Address => 156 Alphand St. Actual: Phone => 1-541-754-3010, Name => J Steeve, Address => 156 Alphand_St. Random_Tests Expected: equal to Phone => 1-681-512-2222, Name => Ray Chandler, Address => Teliman Pk. AB-47209 Actual: Phone => 1-681-512-2222, Name => Ray Chandler, Address => Teliman Pk. AB-47209
I do agree the directions are a bit lacking and you kind have to figure out a lot of the requirements yourself. (Replacing _ with spaces for example).
However, as someone who is trying to improve with regex, this actually helped me learn a lot. So I'm kind of glad the instructions were a little parse.
Go Translation kumited, please review and approve
I can't approve it, I get:
You could report that to CW as a bug.
I can't seem to duplicate the error, no matter how many times I run the tests. did you do anything specific to get the error or just hit run?
Yes I know that I am the only one:-( who can't go on this kata translation... I signalled the bug long ago but had no real response from the staff. @kazk wrote that he had no error and it is very difficult to reproduce the nilClass error. The only thing to do is to ask on https://gitter.im/Codewars/codewars.com if someone wants to approve your translation when the translation is one week old... I am very sorry for you and for myself (I can't add any more my own translations!). I report once more as a bug https://github.com/Codewars/codewars.com/issues/1445.
Approved.
C# Awesome Kata, had a lot of fun solving it. Proposition: I was bit surprised with this case 1-098-512-2222. The test cases are not pushing forward to distinct records (in case if I need to find P Salinge, who just happened to be duplicated, I won`t be able to do that). Cheers.
This comment has been hidden.
The idea behind this kata is good but the description is very lacking in detail, most of the time i spent on figuring out rules from the tests. If the rules were detailed better this kata would be lot better, for now not satisfied
I get this error on one specific test.
Expected string length 75 but was 40. Strings differ at index 0. Expected: "Phone => 8-421-674-8974, Name => Elizabeth Corber, Address =>..." But was: "Error => Too many people: 8-421-674-8974" -----------^
Apparently the suggested phone is found in multiple lines, yet I'm expected to return an entry. This is c# and there has to be a mistake with this test. Apparently its also a fixed test.
This Kata needs to be looked over, way too many bugs across different platforms from what I read.
It seems it was already reported by pizzaman3000 before, if you're sure it's a bug, raise an issue.
In
dr
you have+48-421-674-8974
and8-421-674-8974
... which are not the same so your:is false. Don't conclude too fast about the need to "look over":-)
And I thought my 47 lines was overly complicated. Geeze!
The formating work is too complicated for me without learning right expression.
What a mess. This kind of assignment makes me want to leave the industry. It's silly. The task is ill formed, underspecified and misguided. Don't do this.
Good kata, thanks a lot.
Hello! C#, it seems that Anastasia and Elizabeth Corber have the same phone number but expected answer is all about Elizabeth Corber... Is it an issue or I dont understand the concept? (-:
This comment has been hidden.
Just one suggestion. I found this kata particularly hard and not because the exercise it's hard by itself. I found it hard because I think instructions could be somewhat improved:
1.- Explain invalid characters. I know there is awesome people that can see this rule even if it is not present in the visible test cases/examples. But mortals like me needed to change their design several times because each time a new rule appeared.
2.- Explain that several spaces or underscores must be replaced by single spaces. Again, I'm just a mortal, and took me a long time to be guessing some rules that weren't explained.
Despite of this it's a good kata, thanks for this kind of exercises. Regards!.
Fully agree. I have done some annoying trial and error to find the correct rules. This should be explained in detail in the description, otherwise it is impossible to solve the Kata with the first try.
There should further be a comment that strings between angle brackets <...> are not shown on stdout/stderr (with C++). That also bothered me at the beginning for some time.
Hello all, I'm getting "Caught unknown exception" message, when I tried to run examples. What is the problem? My program runs in my IDE.
When trying to print a string that contains (< >) characters, they are not printed,
Why is this happening?
That's a bug/feature with the output console. It interprets the stuff output as HTML rather than as plain text.
It is supossed that different contacts are separated by "\n" ?
Yes, look at example tests.
I pass the example test!, but test cases not. For example, in the description you wrote:
But in the test cases there aren´t any
< or >
to locate the name, so all the tests, are failed (name not found)I am seing that due to a unknown reason, codewars console is not printing what is between
< and >
(both characters included). Do not why :-(Without that i am not able to figure out what´s going wrong....
JS? Yes it seems that
<
or>
are not printed to the console at CW. Kind of bug. Be sure that the name in the tests are always enclosed as said in the description. 90 guys passed the JS translation so I think it is doable. You can use regex.I am in Java , not JS, I will try it in JS, but I will be grateful if you can solve it for Java, Thx, TDRS ;)
+48 is the country code for Poland. For Italy, you dial +39.
OK but that doesn't matter:-) Nothing is real in these addresses!
Hi. My code runs the tests properly. But, when I submit, I got the two results Failed, and all I see in return is a red cross followed by the nomber "22". Anybody can figure out why is this happening? Thanks.
Test Results: test1(PhoneDirTest) Log Fixed Tests: phone ✘ 22 test4(PhoneDirTest) Log Random Tests ✘ 22 Completed in 99.030345 ms
When I run the test I get in return:
Test Results: test1(PhoneDirTest) Log Fixed Tests: phone ✔ Test Passed Completed in 101.397489 ms You have passed all tests! :)
First I don't think that is an issue of the kata since lots of guys passed it and the tests are the same in all languages, maybe you have a problem in your code. Don't post an issue unless you are quite sure of your code.
Then, to see what exactly happens you could print the input.
At last if you have passed all tests all is well:-)
I submitted my soluton in Java and it works OK. I guess I have some serious issues with the use static methods. My solution would have been a lot cleaner and easier to test had this problem removed the static keyword modifier from the phone method.
my result "Phone => 48-421-674-8974, Name => Anastasia, Address => Via Quirinal Roma" should be equal "Phone => 48-421-674-8974, Name => Anastasia, Address => Via Quirinal Roma", gives me fail. doublechecked comparing strings in Ruby, they are equal. What should be the problem? Checked for extra spaces, all seems ok.
Expected: "Phone => 48-421-674-8974, Name => Anastasia, Address => Via Quirinal Roma", instead got: "Phone => 48-421-674-8974, Name => Anastasia, Address => Via Quirinal Roma"
I suggest you print your output to the console and replace all the spaces with a character e.g.
*
and make sure you're not adding any extra, the reason is the html formats the spaces when it is displayed.Also this should probably be marked as a
Question
because people have solved the kata before in ruby and you are not sure if it is an issue with the kata or not. :)i've read through questions, to many complaining on whitespaces, i've checked that resulting string is equal to expected in ruby, it returned true.
all the questions complaining about whitespaces has been the fault of the user not the kata.
Thanks matt!
so give it a hint. you can't say by the screen why answer is wrong. you just keep waisting time. think this is obvious, that you have to change something if you keep receiving those Q.
My ruby solution is passing all 20 basic tests, but failing the random tests with the error:
Is there a problem with a test, or can anyone help?
Thanks
That looks like an error with the test cases, to be sure post your solution below and mark it as a spoiler because this kata has been passed before in ruby. :)
This comment has been hidden.
it looks like object you are trying to 'measure' is null
am I missing something? this test failed, but my result seems to match the expected. Expected: "Phone => 1-908-512-2222, Name => Peter O'Brien, Address => High Street CC-47209", nstd got: "Phone => 1-908-512-2222, Name => Peter O'Brien, Address => High Street CC-47209"
Check your spaces, when they are displayed on the console spaces are trimmed between words.
yes thank you that worked!
My code fails on the first test:
What is the error?
Seems that you succeeded
Yes, I guess it was a space issue, and like others have observed, the console removes them. Thanks, for the kata.
It seems to me that when I've split the whole input string on newlines (to get each entry), and even before that, the names are missing. That is, there are no angle brackets (< >) at all, and nothing which would have been between them. Maybe this is due to over-active HTML cleaning or something?
Which language?
Ruby.
Nothing is missing in the kata data...
Well that's the thing, it's presumably present in the data, but it doesn't even work with strings I make myself (or in the test cases, which I can see directly have the names in them). I tried:
And the output was
test
. I think this might be related to ruby string interpolation actually. Perhaps ruby is looking for a variable to substitute into the strings in place of<something>
, and, findingnil
, uses the empty string? I can't be sure.Did your tests fail? What did you get? 20 guys passed the kata in Ruby without problem.
I have the same issue using python 3
88 guys passed the Python kata. I just tried a few solutions with CW Python 3.4.3 and everything worked fine. What is the output of the failing test?
Assume they are there. They are just being interpreted as HTML on output, and thus not shown. You can see them actually in the webpage source.
whether test java works properly? Test case with number 8-421-674-8974 expect Phone => 8-421-674-8974, Name => Elizabeth Corber, Address => Via Papa Roma but in text I don't see Elizabeth Corber. My solution return Too many people: 8-421-674-897
The data for "Submit" tests is much longer and there is an
Elizabeth Corder
. I am afraid there is an error in your program. Be sure that the tests work properly:-)thanks, I got this.
Good solution!
These is an error in JavaScript random tests:
Expected: Phone => 18-967-645-8195, Name => Peter Reedgrave , Address => New-Bern TP-16017
. In other examples spaces around names addresses and phones are trimmed.Sorry for that but the random tests were modified by @matt c and I entirely trusted him. Nevertheless I will message him so he could have a look but I don't understand how a given solution can pass the fixed tests and the random tests if they are not in the same format...
ill look into the issue asap
This comment has been hidden.
This comment has been hidden.
Don't worry, it was not that easy to re-use that bunch of data! You are on your phone, quite normal for this kata:-)
I tried to submit several times and eventually the solution passed. I guess random tests try only subset of this huge data set and sometimes this particular entry is not cover. If the data set is predefined are randomness really necessary? Wouldn't be easier and safier to always check all of entries plus some random invalid numbers?
as i'ved provided a hardcoded solution it is possible to cheat, the random tests work just some items were faulty because i wrote them out by hand, fixing the data isn't hard at all
@Freywar: I had as you said a huge data set and random cases but matt thought there was a possibility to cheat by setting a dictionary so he made the random tests more random by mixing names, addressses and phone numbers with a beautiful function. I am sure he will succeed to fix the faulty cases. Thanks for your post.
This comment has been hidden.
This comment has been hidden.
@matt c: thanks again for your work!
Hi, I this there is an issue on this test using Python. I was using strng.splitlines() and each substring was correct except the "" elements were mysteriously missing from each new string. When I tried simply returning the original phonebook string with no modification I saw the same thing - the "" elements were missing in the string as well.
Please could you be clearer, I don't understand very well your problem:-(
Sorry I figured it out. My browser (chrome) was just not rendering the strings "LEFT BRACKET name RIGHT BRACKET" when I tried to print them, but was properly rendering them in the project description and the provided print statements. I don't know HTML so that is probably some sort of special combo.
Thanks for your post!
Hi I think there's an issue with the test:
For the line:
+5-541-984-3012 /PO Box 5300; Albertville, SC-28573
Expected: Phone => 5-541-984-3012, Name => Peter Reeves, Address => PO Box 5300 Albertville SC-28573,
Instead Got: Phone => 5-541-984-3012, Name => Peter Reeves, Address => PO Box 5300 Albertville, SC-28573
For the line:
133, Green, Rd. NY-56423 ;+1-541-914-3010
Expected: Phone => 1-541-914-3010, Name => E Kustur, Address => 133 Green Rd. NY-56423
Instead Got: Phone => 1-541-914-3010, Name => E Kustur, Address => 133, Green, Rd. NY-56423
Please which language? Fixed or random tests? I am pretty sure there are no problem with the tests but it seems that you have extra commas in your results.
My bad! I was interpreting the trailing comma at "SC-28573," as part of the string wheras it was part of the testing framework's message.
Thanks for your post but for the future don't post an issue before being sure of your code. Issues are for flaws in the kata, you could simply post a question:-) Posts can be labelled with "Issue" "Question" or "Suggestion".
This comment has been hidden.
Thanks for the feedback!
I tried to solve it without using regex. Most of the solutions using regex are 5~10 times slower.
Some information becomes only available until after code is submitted, e.g. the requirement that some characters such as under_score, semicolon etc. need to be converted to spaces. That should be already given in the description - and ideally in the initial test data as well.
You can see in one of the examples that underscores, semicolon, "<" and ">", "/", "+", "!", etc... have to be removed :
and the description says that
lines are cluttered with non-alpha-numeric characters
which lets us suppose that they must be removed. The data "dr" and the "examples test cases" are another way to see that. Even so I can't give the good regexp:-)This comment has been hidden.
This comment has been hidden.
The info are found when looking at the examples and at the given "Your examples test cases". You could also print the input and see what it is expected. You must keep the alpha-numeric characters as said in the description plus"-" for the phone nums, "<" and ">" to find the names, duplicate spaces could as usual be replaced by single ones. Think that it is the same problem when you try to decode a Web page with hidden chars.
I do not think there could be a good description on this kata except all the test cases shown or all possible chars declared. Such code can run out with correct result only under certain condition, which means you should know all the conditions. Thanks to the
console.log
we can know hwat line comes and then hwat to fix, or we could only get mad.Maybe it is the same problem when you try to decode a Web page with hidden chars?
yes, it is alike but at least you can view the source code at first to determine the char set... this site works terriblly on phone browser anyway.
I think there might be a small problem in the way the Java version of the kata handles ' symbol. For "Peter O'Brien" the expected name output is "Peter O Brien", but I guess given the way it's normally written, it would be better not to omit '.
You are right, I have a small typo in the Java and C# version. I will try to correct them. I said I will try because it is not often easy to re-edit a Java translation. Thanks!
I succeeded but unfortunately your solution is now invalidated, sorry for the inconvenience:-(
thank you! Now the main tests are treating this properly. However Your Test Cases part still expects "O Brien" so it might be confusing testing(PhoneDir.phone(dr, "1-908-512-2222"), "Phone => 1-908-512-2222, Name => Peter O Brien, Address => High Street CC-47209");
Maybe it was not updated. I just verified "Your Test Cases" and I can read:
Do you see now the same as I do?
yes, now it's all good: testing(PhoneDir.phone(dr, "1-908-512-2222"), "Phone => 1-908-512-2222, Name => Peter O'Brien, Address => High Street CC-47209"); It just probably took some time for all of the tests to update.
I thank you very much for your help!
I am new here. Can anyone tell me how can I see all the Kata of a particular tag? The kata keeps on refreshing randomly. I started solving one problem and somehow it got refreshed and now I am unable to find it.
When you go to your profile, you should be able to find it if you click "Unfinished" under "Kata:"
too much cleaning in string
I don't understand why it is an issue. What do you want me to do? BTW you have a very good solution.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
It will take as long a time to create the dictionary as to solve the kata, don't you think so since the given data are already rather long? There are already random tests maybe not elaborate enough but sufficient to take a lot of time by trying again and again the "Submit" button. Furthermore cheaters cheat only themselves and I can see so many katas with only 3 or 4 fixed tests... A solution for that kind of kata would be that at CW, in the preloaded section or elsewhere, one can put a rather long file but it is not (still?) the case. If you have time you could write some more elaborate random test cases and I'll certainly agree with them. I see your post more as a suggestion than an issue. Nevertheless I thank you very much for the feedback.
yeah, sorry about that, I do see now that raising it as an issue was over the top. I would gladly attempt at writing some more elaborate random tests and post them below :)
Thank you so much for your proposition! Don't be sorry, you are welcome! I'm waiting:-)
This comment has been hidden.
There ya go, a bit big but that's because of fixed values which can be changed to dynamic if you really wanted. :)
P.S. I just really like making random tests :)
Wow! What a good job! It will take me time to look at that! I still ask you a favor (I have not lots of time now...) : could you add your completely random tests by editing the kata and add in the description something like " JavaScript random tests completed by @matt c"? Anyway, whatever you will do lot of thanks again:-)
yeah, that's cool! just wanted to make sure you were cool with the changes first :)
Sure I agree! Twice rather than once. Your code is excellent and sophisticated, so better than mine! I wish I knew as much as you. I rake wide but shallow:-) I tried your site http://www.slothpie.com/ (I wanted to write directly to you) but it timed out:-(
Thank you very much! I wish I knew as many languages as you though!
ahh, yeah I cancelled my vps which was just hosting this platformer I started a long time ago but haddn't finished. It's on my github though. I might get another vps soon and put something on that link :)
This comment has been hidden.
Thanks for your edit! I don't think it is possible through github but if neccessary I think I find some way:-)
This comment has been hidden.
Corrected, thanks!!!