5 kyu

Phone Directory

241 of 6,926g964
Description
Loading description...
Fundamentals
Strings
  • Please sign in or sign up to leave a comment.
  • SummerTheCoder Avatar

    Bad kata, didn't like it.

  • ahmet_popaj Avatar

    Very nice kata to practice with.

  • daccess1 Avatar

    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.

  • TheWitcher Avatar

    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...

  • jkimbell Avatar

    This wasn't that bad without regex (in Python).

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • arthurshlain Avatar

    This comment has been hidden.

  • ah2023 Avatar

    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.

  • ah2023 Avatar

    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.

  • ib1zza Avatar

    testcases are broken for js correct answer cant be readen

    no description for output address format (like trim spaces)

  • ejini战神 Avatar

    JS mocha + chai framework should be used

  • ejini战神 Avatar

    Ruby 3.0 should be enabled

  • lcaballero Avatar

    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".

  • Horneringer Avatar

    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.

  • Princess Aura Avatar

    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.

  • tohanilhan Avatar

    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...

  • Tom H. Lautenbacher Avatar

    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.

  • hgsg Avatar

    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.

  • kvesterr Avatar

    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.

  • Ebrelus Avatar

    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

  • Matteo Zattera Avatar

    For the string:

    " 133, Green, Rd. <E Kustur> NY-56423 ;+1-541-914-3010!\n"
    

    what is the address?

  • delsix Avatar

    This comment has been hidden.

  • vmbot Avatar

    This would've been crazy to solve without looking at the inputs being supplied.

  • DanWebDev1980 Avatar

    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)/, ' ');

  • volodkaly Avatar

    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.

  • bcaixl Avatar

    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???

  • oleksiiB Avatar

    It would be nice to have "Regular Expressions" tag added here

  • piocyg Avatar

    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.

  • azunai Avatar

    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

  • nettumenetwork Avatar

    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

    1. I am revieving an error message because the expected and recieved are not similar to the exact number of spaces(nothing wrong about at) BUT the exact issue os that this occurs for a single phone number doesn't happen to the others, and it is expecting/requiring a single double space? between the address's street name and the word street itself? For example: Expected: ...Address => Solomn[ ]Street
      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:
    2. I am given two numbers that are the same each one leads t na different person and it requires me to print out the second of the numbers. I held a previous expectation that given 2 instances where the number could lead to that you should output a string similar to "Error:too many Numbers". But this flipped that. Its easy to fix and change this of course but I am disaapointed by the lack of information that the rules for this kata where not more specific. I am still debating whether this was intentional or a just some bug. because in the test, it seems to have expected me to output that error string when given the two numbers instance mentioned previously but in the attempt its now different.
  • Mohrezakhorasany Avatar

    It was a great kata, Thanks for sharing it!

  • LittleEwok Avatar

    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.

  • and-kushnir Avatar

    Amazing Kata)

  • salvin18 Avatar

    This comment has been hidden.

  • GoldenMaximo Avatar

    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.

  • Urfoex Avatar

    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...

  • joykim92 Avatar

    This comment has been hidden.

  • uinku Avatar

    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"

  • fgol Avatar

    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.

    • Do the tests require a trailing \n?
    • Is there white-space other than space (ASCII 32) I need to look for??
  • zgagato Avatar

    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

  • Ben Williamson Avatar

    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.

  • zluther89 Avatar

    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?

  • evgeni-nabokov Avatar

    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.

  • NAPOLEON039 Avatar

    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 every Attempt, 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.

  • branne Avatar

    Yeah I'd stay away from this. The solution is pretty simple but the tests are brittle which is very frustrating.

  • dch216 Avatar

    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).

  • DolphieDude Avatar

    Address form is not specific in rules. Please, rework a bit instructions. Underscores should be replaced with space, forbidden ";", "&" and etc.

  • MartinKondor Avatar

    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 a dict which is not just more readable but this is what we would do in real life:

    {
      "phone": ...,
      "name": ...,
      "address": ...
    }
    

    There is no reason here for using strings like this.

  • dcress Avatar

    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?

  • noschm Avatar

    I had a lot of fun with this kata. Thank you for this!

  • awesumyea Avatar

    This comment has been hidden.

  • arbboter Avatar

    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

  • spencerfcp Avatar

    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.

  • Helge801 Avatar

    Go Translation kumited, please review and approve

  • NGUgeneral Avatar

    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.

  • kevinchannon Avatar

    This comment has been hidden.

  • acambas Avatar

    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

  • DanailKazakov Avatar

    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.

  • erichlf Avatar

    And I thought my 47 lines was overly complicated. Geeze!

  • user4273297 Avatar

    The formating work is too complicated for me without learning right expression.

  • sehe Avatar

    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.

  • dulot Avatar

    Good kata, thanks a lot.

  • pizzaman3000 Avatar

    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? (-:

  • RafaARV Avatar

    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!.

  • Erdemiko Avatar

    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.

  • Toderesa97 Avatar

    When trying to print a string that contains (< >) characters, they are not printed,

    strng = "/+1-541-754-3010 156 Alphand_St. <J Steeve>\n 133"
    //what is printed is:
    /+1-541-754-3010 156 Alphand_St.
    133
    

    Why is this happening?

  • Toderesa97 Avatar

    It is supossed that different contacts are separated by "\n" ?

  • kprzygudzki Avatar

    +48 is the country code for Poland. For Italy, you dial +39.

  • elDucUrraca Avatar

    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

  • mikesmithson Avatar

    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.

  • 6eff Avatar

    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.

  • hannako Avatar

    My ruby solution is passing all 20 basic tests, but failing the random tests with the error:

    "Random Tests"
     `phone_sol44': undefined method `length' for nil:NilClass (NoMethodError)
        from `tests'
        from  `
    

    Is there a problem with a test, or can anyone help?

    Thanks

  • ptascio Avatar

    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"

  • ecolban Avatar

    My code fails on the first test:

    'Phone => 48-421-674-8974, Name => Anastasia, Address => Via Quirinal Roma' should equal 'Phone => 48-421-674-8974, Name => Anastasia, Address => Via Quirinal Roma'
    

    What is the error?

  • 98devin Avatar

    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?

  • ubaw Avatar

    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

  • Freywar Avatar

    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.

  • phuse2 Avatar

    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.

  • Davste93 Avatar

    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

  • seasidetesting Avatar

    This comment has been hidden.

  • seasidetesting Avatar

    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.

  • Augustin82 Avatar

    This comment has been hidden.

  • sinri Avatar

    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.

  • elellle Avatar

    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 '.

  • codegear Avatar

    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.

  • Darigaaz Avatar

    too much cleaning in string

  • matt c Avatar

    This comment has been hidden.

  • ChristianECooper Avatar

    This comment has been hidden.