Ad
  • Default User Avatar

    just wondering, where in this solution does the block return true or false to update @items_processed?

  • Custom User Avatar

    Yustynn did a great job explaining what I meant.

  • Default User Avatar

    I'm new to programming, but I think he's talking about having two iterators instead of one.

    In the original solution, you had ruby run through each element one by one to filter out unwanted elements. Then you go through those selected elements one by one again to sum them up.

    His solution does it all one shot. In his inject, he goes through the elements one by one but performs both actions (filtering and sumation) before moving on to the next element. Meaning that instead of running through all the elements twice (once to filter, once to sum), he does it once and he's done.

    So worst case: all integer values. All elements are run through once, none are rejected. Then all have to be run through yet again to sum. Two run throughs instead of one, so supposedly 2x the time taken.

  • Custom User Avatar

    Could you explain further? I am trying to get my head around why it'll require twice as much computing in worst case.

  • Custom User Avatar

    After 1.9, hash enumerations use the order of insertion.

  • Custom User Avatar

    Hey shotop, what do you mean by basic debuggging? I couldn't find what's being passed in.
    Did you check the network and xhr files ?(Also getting an error on the third)

  • Custom User Avatar

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