Ad
  • Custom User Avatar

    Because only rows 1 & 2 are reported. Row 0 becomes [0,0,0] after 'S', and the instructions state that the smallest possible array is reported where any row or col has any element > 0.

  • Custom User Avatar

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

  • Custom User Avatar

    Thank you Geoff for replying, I am currently thinking about ways to achieve that.

  • Custom User Avatar

    After a bit of reading my solution is probably O(n^3), way off the mark! I'm having trouble imagining another solution that doesn't get into more loops to perform some sort of look-around (effectively my original solution). Memoization seems a bit of a stretch also (but I may be wrong).

  • 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

  • Custom User Avatar

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

  • Custom User Avatar

    You don't need a sieve to calculate prime factors. Its OP. Look at trial division.

  • Custom User Avatar

    Yes, I'm aware of that one as well. @functools.cache is a newer version of lru_cache and supposed to be faster, but is > 3.9 only.

    Turns out memoization wasn't the solution to my problem anyway.

  • Custom User Avatar

    Oh! My bad, it's a 3.9 addition. I'd read the docs wrongly. Apologies.

  • Custom User Avatar

    Are the newer Python 3.8 decorators supported? I'm trying to use @functools.cache and receiving an error after functools is imported. This works fine locally on my machine. I want to use this to memoize my functions as I'm currently hitting the execution timeout on the full test suite.

    Traceback (most recent call last):
      File "tests.py", line 1, in <module>
        from solution import *
      File "/workspace/default/solution.py", line 3, in <module>
        class DirectUnweightedGraph:
      File "/workspace/default/solution.py", line 37, in DirectUnweightedGraph
        @functools.cache
    AttributeError: module 'functools' has no attribute 'cache'
    
  • Custom User Avatar

    Chrono79, thanks. btw, sorry for flagging it as an issue instead of a question. First discourse post, etc. etc.

  • Custom User Avatar

    Now you're asking! Possibly eastern syllabic languages but I'm no expert. eg Tibetan has it's own punctuation for ends of sentences etc but nothing AFAIK for 'word' delimiting. I can't read it, I just chant it...

  • Custom User Avatar

    Agreed, that feels very artificial just to simplify the splitting process and thus the testing process. I coded mine to deal with the eventuality there isn't a space before punctuation.

  • Custom User Avatar

    Agreed, that feels very artificial just to simplify the splitting process and thus the testing process.

  • Loading more items...