Ad
  • Custom User Avatar
  • Custom User Avatar

    What regex can consistently get countries from string like these:

    "Citizens of Impor, Arstotzka require passport"
    "Citizens of Kolechia require passport"
    "Deny citizens of Arstotzka, United Federation"
    

    I solved it without regex (check solution because spoiler)

  • Custom User Avatar

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

  • Custom User Avatar
  • Default User Avatar

    Perhaps my description of the kata will make more sense:

    Description
    Amidakuji is a lottery method designed to create random pairs between two sets of the same size.In this kata the elements of the first set are whole numbers from 0 to 6. Your task is to write an amidakuji function that returns second set comprised of converse numbers.

    Input
    Your function will receive an array of equal-length strings consisting of 0 and 1 characters; this represents the "ladder" structure. The 1 represent the rungs of the ladder and the 0 represent empty space.

    const ladder = [
        '001001',
        '010000',
        '100100',
        '001000',
        '100101',
        '010010',
        '101001',
        '010100'
    ];
    
    amidakuji(ladder); // [4, 2, 0, 5, 3, 6, 1]
    

    Take a look at the diagram below:

    Row 0 of the ladder is '001001' string, which means there will be two horizontal bridges at this row; one between the vertical lines 2 and 3 and another between vertical lines 5 and 6. When proceed to move down vertical lines, a transition is made to the adjacent vertical line over the nearest bridge.

    Output
    The diagram above is a visual representation of ladder argument of the function.
    At the top of the diagram the 2 has a third position, in the aftermath of the ladder it got a second position. The yellow highlighted path shows the path taken by the 2 value. Every time it encounters a bridge, it moves to the opposite vertical line.

    Your function should return an array of numbers, with each number in its final position.

  • Custom User Avatar

    When I was trying to submit a python solution, it passed all the fixed tests, but when it got to random I got an error

    Traceback (most recent call last):
      File "/workspace/default/tests.py", line 139, in <module>
        for i in range(20): test_fnc(*test_gen(RN(5)+20,RN(6)+7,2))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/workspace/default/tests.py", line 136, in test_fnc
        test.assert_equals(blast_sequence(nx,ny),ref_funk(nx,ny))
                                                 ^^^^^^^^^^^^^^^
      File "/workspace/default/tests.py", line 53, in ref_funk
        mv = zv + y
             ~~~^~~
    TypeError: can only concatenate list (not "int") to list
    

    My solution seems to work with the random test cases, but somehow it still gives the error

  • Custom User Avatar
  • Custom User Avatar

    Unless I've gone blind, there's almost nothing explained about the Allow/Deny a nation. Do I have to check in a whitelist manner (nation has to be in allow list) or blacklist manner (nation must not be in deny list) or do I combine them to one list in either manner, where one method removes from list, other adds to it? Additionally, do the countries aggregate or get reset between days?

  • Default User Avatar

    i'm coding in the golang version and i'm sure there's something wrong with one of the tests

    given that the lower bound is 100000 and the upper bound is 12345678900000000, but somehow the answer is only 718650, which from what I calculated is way less then just the total for a 16 upside-down number sum. So, now im also wondering if actual tests are correct or not.

  • Default User Avatar

    That was a really nice kata

    One small suggestion; the description states:

    A player who completes the fourth side of a 1 x 1 box earns one point and takes another turn

    It left me wondering whether completing two boxes at once provided with 2 extra turns or only 1. It turns out it is the latter. Perhaps this could be mentionned ?

  • Default User Avatar

    C++ translation published

  • Default User Avatar

    In Java's sample tests (sampleTest2) :

    The assertion:

    assertFailPopulate(blobs, invalidGen);
    

    always succeeds because in assertFailPopulate():

    try {
        blobs.populate(genToLstOfMap(gen));
        fail("Invalid elements should trigger a RuntimeException in 'populate'");
    } catch (RuntimeException e) {
        assertTrue(true);
    }
    

    the genToLstOfMap() (which is a tests suite function, not a user function) throws a nullPointerException when called on invalidGen, and nullPointerException is an instance of RuntimeException. So the assertion always succeeds and the user's code is not even called.

  • Custom User Avatar

    This solution in JS should be patched

  • Custom User Avatar
    • Entry denied: missing required work pass.

    • Passport check case for Ban nations and expiry date

    Above cases are not guaranteed in JS at least (should have fixed tests for that)

  • Custom User Avatar

    Although I have yet to solve the kata, I had found some troublesome issues that are discussed in discourse but not stated or highlighed clearly in description. (More to add as time goes...

    • Description does not mention that the given examples of bulletin rules are strictly written in such format. In other words, solvers may assume cases like below will occur

      • Foreigners do not require access permit

      • Workers do not require work pass

      • Do not allow citizen of Republia

      etc...

    • Description does not mention accumulation of bulletin rulesets are to be expected and preceding bulletins for following days will override existing / previous ones. It only mentions criminals should be handled based on the bulletin given on that day.

    • Description does not mention that by-default, all nations except Arstotzka itself will be denied.

    • Message formatting for mismatch information resulting in detainment is not specified. Only example below is mentioned. (So, what about Nationality, name, DOB etc. mismatches???)

      If due to information mismatch, include the mismatched item. e.g.Detainment: ID number mismatch.

    • Same goes for expiration validation on different documents (No implication that _ are to be replaced with space)

    • The specification for vaccination is unclear.

      • Will each entrant receive more than one vaccine??? (Yes, apparantly...

      • How is the bulletin for vaccination defined??? Is it that~~ ??

        • The next bulletin ruleset regarding vaccination will always negate the previous case , with possibly additional ruleset for allowing other kinds of vaccinations for specific regions (EX: Entrants require tetanus vaccination followed by Entrants no longer require tetanus vaccination && possibly Citizens of Impor require hepatitis B vaccination)

        • Patially duplicate vaccinations ruleset may occur (ex: Citizens of Impor, Republica require polio vaccination && Citizens of Impor, Obristan require cowpox vaccination)

        • Non-existing vaccination rulesets will be defined (ex: Foreigners no longer require cowpox vaccination with no prior vaccination ruleset beforehand)

        For now, one may assume only the 1st case occur based on the test cases, but it is not guaranteed anymore...

    • Does not mention the validation on required documents (passports, IDs, permits (if any)) should be done before vaccination validation

  • Loading more items...