Ad
  • Default User Avatar

    Sorry – I had just checked that your "cheat" solution had been invalidated and that none of the other ones were.

    I've implemented your suggestion and now it should be fixed. 😅

  • Default User Avatar

    Should be fixed now 👍

  • Default User Avatar

    It's just that no one has approved it yet. Maybe there aren't enough Julia coders who can approve translations.

    It seems like some translations do take a long time to be approved. Some of the ones for this kata have been waiting for 17 months! I'd say the site probably needs to overhaul the whole way that translations are approved.

  • Default User Avatar

    Congrats! And thank you for the kind words.

    Yes, I picked the maximum number of islands carefully 😈

    Out of interest, what kyu rating would you give it?

  • Default User Avatar

    Everyone's is! 😅

  • Default User Avatar

    Hmm... maybe another hint then, or at least something to try: some people made use of heap queues, which I've found seem to speed up even non-optimal algorithms dramatically (especially ones where you need to repeatedly find the minimum item).

  • Default User Avatar

    I wouldn't say it's that obvious. Personally, I think this should be 3 kyu – it was approved when it was easier, before I could increase the number of islands as much as I fully intended. Now it's stuck at 4 kyu 🤦. Just be thankful you're not doing it in JS – that version has 15,000 islands 😅! But anyway, you're 1 kyu, so it shouldn't be too much of a problem.

    But if you're really stuck, here's a hint (I'm pretty sure you already know it though)...

    
    I used a modification of the algorithm that rhymes with Kim's algorithm. Other people did it in cleverer ways though, so use your imagination 😝
    
  • Default User Avatar

    Thanks for the feedback. I've put in the description that the coordinates are real numbers, and I've added "performance" to the tags.

    The module forbidder was written by someone else, so I might have to get his input on the numpy thing if I can't figure it out myself. It's probably because numpy imports sys, but I'm not sure how essential it is to forbid sys. It might be that either sys gets allowed (and a way to "cheat" gets opened up) or I'll have to add numpy to the list of forbidden modules. What did you want to use it for, out of interest? None of the (now invalidated) solutions that I can see used numpy before the module forbidder was implemented, except to prepare arrays for feeding into scipy.

    EDIT: It's fixed now – you should be able to import numpy.

  • Default User Avatar

    and Amy gets elected with 2 first choices

    No – the first choice votes are only counted once (in step 1). After that, candidates only get allocated more votes when a candidate above them is elected or eliminated.

    In this case, in round 2, none of the candidates have reached the quota, so Amy is eliminated because she has no votes and comes first alphabetically.

  • Default User Avatar

    That process looks correct to me (with 1 and 2 being part of step 3, not step 4), but a bit of clarification is needed. Technically, the process is designed such that the first choices count for one vote up to the quota, over which they are re-distributed. But practically, no votes have to be deducted from elected candidates after counting the first-choice votes, so the extra vote fractions given to the next choices can be seen as a bonus.

    Your algorithm can keep elected candidates on the ballots if needed to ensure the total vote counts are correct, but an algorithm that records them as elected and then removes them from the ballots should produce the same results.

    If you think this means the description needs amending, let me know.

    EDIT: Why would this mean the second sample test is incorrect?

  • Default User Avatar

    If a ballot becomes empty, the vote does not get transferred (i.e. no vote is counted from that ballot). I'll update the description to clarify this.

    If there are multiple candidates elected in the same round, shouldn't all other elected candidates be removed from the ballot too?

    Yes. They are elected in step 3 and effectively "removed" from all ballots in steps 4 and 5 by this instruction: "find the next choice on the ballot that hasn't been elected or eliminated". Practically, you can remove them or just ignore them, of course.

  • Default User Avatar

    Is 500 islands the most it can do before timing out? If so, is that because of the innate speed of R or the algorithm you used?

    EDIT: Just saw your comment – apparently the algorithm is pretty optimized. Weird that R can only do 1/10 of the islands that Python can in the same time (and 1/30 of the islands that JS can!).

  • Default User Avatar

    You're definitely on the right path.

    In my first reply to you (that was hidden as a spoiler), I explained why the tests take so long even if you just submit a function that returns immediately. It's because the reference solution needs to calculate the answers for each of the random tests, regardless of what your function returns. That was what was taking 6 seconds before. But with the help of RileyHunter, we optimized the reference solution so that now it only takes about 0.75 seconds for 15,000 islands (!). That means you have more than 11 seconds to work with now, so make the most of it 😅.

  • Default User Avatar

    Hey all! I made a Julia translation. Would appreciate it if any reviewers who are fellow Julia fans could take a look.

  • Default User Avatar

    Hey all! I made a Julia translation. Would appreciate it if any reviewers who are fellow Julia fans could take a look.

  • Loading more items...