Ad
  • Custom User Avatar

    Was able to copy-paste your done into Ideone and get it working after removing the JQuery-style "${}" elements and it returned [1, 7] as expected.

    I'd say double-check the output with print statements just in case.

  • Custom User Avatar

    Given a list of integers and a single sum value, return the first two values (parse from the left please) in order of appearance that add up to form the sum.

    The Kata specifications outline the behavior that makes your current interpretation invalid, since the paired numbers 3 and 7 appear to the right of an alternate complete pair. Try a new solution that follows that spec!

  • Custom User Avatar

    Chrono79 made the basic point, but I'll also chime in here. Consider massive data optimization as something that can help your resume! There's a big difference between an engineer for a local small business who can manage thousands of users' data a month versus an engineer who can optimize for thousands of requests per minute. That's the kind of difference that lets someone work for a AAA company or not.

  • Custom User Avatar

    Mind sharing your code? You can mark it as a spoiler and we can help take a look to see where your approach is eating up time.

  • Custom User Avatar

    It may be that the tests are expecting a specific named function to be defined, but the compile process is determining it hasn't been defined/created.

    Have you tried renaming your function to 'sum_pairs' to see what happens?

  • Custom User Avatar

    Can you provide more information here? The examples and details on the Kata explain from the get-go the types of cases that will appear, as well as the fact that there will be a need to write an efficient algorithm due to the requirement of having to handle lists with 10 million elements.

  • Custom User Avatar

    I'm late to respond to this, but after taking a look at the mere fact that you went and made a COBOL translation and that it (presumably) works, I felt a deep fear like writing up a post-mortem for a cancelled year-long project.

    I personally don't have the expertise required to gauge if the translation is good enough, so I'll defer to people more intelligent than me to make that call.

    I bow to your knowledge of the Old Ways.

  • Custom User Avatar

    I respect your opinion.

    For many people, this problem has appropriate wording, while for others it's misinterpreted. In real-world scenarios, being able to reach out and discuss with others and doing investigation is what makes a difference between a substandard and a great developer.

  • Custom User Avatar

    the order of the books in the sublists and the order of the sublists themselves should by specified

    This requirement was removed. My solution checker handles the nested list appropriately to ensure lists like the following are considered equivalent:

    [[1,2],[4,5,6],[100]]
    
    [[100],[1,2],[4,5,6]]
    
  • Custom User Avatar

    Ah, I believe you're correct, at least in regards to the worst possible runtime.

    After looking into it, this seems like a rendition of the Knapsack problem, which is NP-complete—specifically, as a 0-1 knapsack problem.

    However, there are psuedo-polynomial runtime approaches to the problem using dynamic programming, and this approach lands a runtime between O(nW) [where W is the word limit] and O(2^n); meanwhile the space requirements are only O(nW)

    See the example here https://en.wikipedia.org/wiki/Knapsack_problem#0-1_knapsack_problem

  • Custom User Avatar

    I was hoping for a runtime like the famous Word Break problem (check if a string can be made up of any combination of provided dictionary words), which is O(nlogn), IIRC.

    A pure brute force solution would require O(n!), since you would need to check every combination of books possible per book checked.

    With some memoization or clever arrangement of the problem parameters to avoid revisiting elements, I believe the runtime goes down to O(n^2) (with the true complexity being n(n-1)/2).

    EDIT: The runtime values determined here are incorrect. Please see the thread directly above this one.

  • Custom User Avatar

    There are two examples of that in the visual representation breakdown. A set of one object is contained within a larger set of two objects, so it is ignored.

    A set of one object is still a set.

  • Custom User Avatar

    Ok? Thanks for your feedback. Not really a suggestion though.

  • Custom User Avatar

    Thanks for the suggestions! I've gone ahead and made a visual representation of an example problem pass, and included some examples without the visual aids at the bottom of the problem description.

    Let me know if there are better ways to introduce examples to a user or if you have any other recommendations for this problem! :)

  • Custom User Avatar

    Thought about using a memoized approach here, but wound up with a rather brutish approach IMO. Given that less intensive Word Break problem is often O(n^2) time, this might just be a known issue with solving these combination-type problems.

  • Loading more items...