Ad
  • Custom User Avatar
  • Custom User Avatar

    I could only determine an analytical solution to the problem:

    The initial sequence has two odd numbers at indices 1 and 2. Therefore, these combine to an even number and the next two
    terms will be even. The first 7 terms are:

    [0, 1, 1, 2, 4, 8, 16]

    This changes at index 7 because the first odd number slides out of the window to generate a new odd number at the tail:

    [...,1, 2, 4, 8, 16, 31]

    At index 8 the second odd number slides out the window to generate a new odd number at the tail:

    [...,2, 4, 8, 16, 31, 63]

    Therefore, every sextet of terms will be four even numbers and two odd numbers, with odd numbers at positions 1-2, 7-8,
    13-14, etc. The solution generates the required offsets in the cycle with integer division: (n - 2) / 6 and
    (n - 1) / 6.

    The additional constant combines the duplicate 1s at indexes 1 & 2, which are ignored in the calculation ◻

  • Custom User Avatar

    So much shade for the top dog. All the stakeholders I have worked with give perfect requirements that don't require clarifying questions ¯_( ͡° ͜ʖ ͡°)_/¯

    Keep them coming g964, we'll figure it out in the end.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    A couple optimizations are warranted:

    • Remove the last 2 lines of the code block in the description and add to the plain text description
    • You can implement the random string generator as (repeatedly len #(rand-nth "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), or something similar with rand-nth
  • Custom User Avatar

    Good point. This now uses a list of candidate names to generate an input list of up to 100 names. Thank you!

  • Custom User Avatar

    Type issue in the test suite?

    test/CalculateParityBitSpec.hs:18:105: error:
    • Couldn't match expected type ‘Int’ with actual type ‘Word’
    • In the third argument of ‘assertEqual’, namely
    ‘(checkParity parity string)’
    In a stmt of a 'do' block:
    assertEqual
    ("checkParity " <> show parity <> " " <> show string)
    (refCheckParity parity string) (checkParity parity string)
    In the expression:
    do assertEqual
    ("checkParity " <> show parity <> " " <> show string)
    (refCheckParity parity string) (checkParity parity string)
    |
    18 | assertEqual ("checkParity " <> show parity <> " " <> show string) (refCheckParity parity string) (checkParity parity string)
    |
    ^^^^^^^^^^^^^^^^^^^^^^^^^

  • Custom User Avatar

    The Scala function should return List[String], not List[String, String]