Ad
  • Custom User Avatar

    Unpublishing due to many long-standing issues.

  • Custom User Avatar

    Linked list is a duplicate to a million existing katas.

  • Custom User Avatar

    Tests are incredibly weak: most tests only involve at most 2 nodes. And there are no random tests.

  • Custom User Avatar

    There are two kinds of to_a in the tests: the instance method to_a and the class method to_a. They're redundant.

    There's nothing to stop us from implementing reverse by converting it to array, reversing it as an array, then converting it back.

    And then suddenly you're putting in a Range object into from_a? Isn't the meaning of from_a, well, do something from an array? What's a Range doing here? By this rate I wouldn't be surprised if we'd have to support Strings and Enumerators as well.

    Did you really think through the requirements when you made this kata? Because it's obvious you don't, you just slap together a bunch of stuff about linked lists and expect people to contemplate into what you were thinking about when writing the tests.

    Besides, you didn't really write up any kind of documentation. If you've done that you should've already seen through most of the problems mentioned above.

  • Custom User Avatar

    Needs sample tests

  • Custom User Avatar

    It's not clear how the String representation of a Node object is supporsed to look:

    • In one case the example is: one #=> <Node @name=1, @next=nil>
    • In another case it's: two #=> <Node @name=2, @next=<Node @name=1 @next=nil>>

    Note, how this is inconsistent: For the second case I'd expect a comma between the value of the @nameand ```@nextIn other words:two #=> <Node @name=2, @next=<Node @name=1, @next=nil>>````

    How about fixing this by having the comma in both cases (in fact all cases -- in case of a longer list)?

    Depending on how detailed the test for the this kata are, it can be confusing for users to fail because of this, without adding to the point of the kata (which is understanding a singly linked list).

  • Default User Avatar

    I, too, really liked this kata and going back to the basics to implement a simple data structure. The couple of comments I have are as follows:

    • Mention that the from_a method actually needs to handle ranges and arrays.
    • It'd be nice if all required methods were listed instead of just the four that are given (reverse, from_a, to_a (class), and to_a (instance)). The complete list of required methods can be gleaned from the given Text Examples, but it'd be nicer to have everything explicitly listed.
  • Custom User Avatar
    1. I show you the full Node class, so why do you complain about it ? You identify the node by the object id, it is enough.
    2. I overwrite the Hash methods because you should no use them, if you write your own hash-like class YOU'RE DOINT IT WRONG.

    "Thanks to shadchnev, I broke all of the methods from the Hash class."

    1. You don't need a method create_chain that's why codewars is here just type your code in the browser and run the tests.
    2. OBJECTIVE : Your objective is to determine the length of the loop. -> How can it be more clearer ?
    3. Use the function #next to get the following node. -> means do not touch the nodes and use the object id to compare the node.
    4. The code is runned on their servers so the timeout is due to your connection or bad solution
  • Custom User Avatar

    Thank you, Abbe! Good points. I added an extra test case line to the bottom of my description, and I now explain that you need to create 2 to_a methods, a class and instance method. Yes, it's useful to implement basic data structures from scratch, instead of depending on a library/gem. That fact that Ruby doesn't have a built-in linked list is bad for programmers but good for us learners.

  • Default User Avatar

    OK thanks hencethus! I'll certainly keep that in mind for future katas

  • Custom User Avatar

    It's not clear from the examples in the description that to_a should be both an instance and a class method. I got stuck there for a while, since the first tests only use the class method.

    I could consider making the tail parameter to the constructor optional as well, but then you'd have to explain that in your examples.

    Personally, I think 'value' is a more natural name than 'name' for accessing the Node's value.

    But all in all, it was a nice kata. Always good to implement some of the basic data structures from scratch once in a while.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Problem should say what the max primes are that it tests up to.

    Rayning and anhkind, for some reason I can't use the 'reply' function. Most of the solutions posted so far don't hard-code in an upper bound. Even one sieve solution generates an upper bound using the prime number theorem.

    Why do you think it should be specified ahead of time?

  • Custom User Avatar

    I'm rayning3 on Skype, if you want to talk. If you have any questions about Ruby, I've been programming in it for over 1 year now. My email is rayning@gmail.com. I'm happy to help! What's your new job? Congratulations.

  • Loading more items...