Ad
  • Custom User Avatar

    Good kata, but there is a problem with Swift unit tests and example

    func swap(_ s: String, n: Int) -> String { // _ is missed before n

    XCTAssertEqual(swap("the quick broWn fox leapt over the fence", 9),
    "The QUicK BrowN foX LeaPT ovER thE FenCE")

  • Custom User Avatar

    Description is inconsistent. Each bit in n will specify whether or not to swap the case versus because 11 is 1011 in binary, so the 1st, 3rd, 4th, 5th, 7th, 8th and 9th alphabetical characters have to be swapped. You really need to describe this more carefully.

  • Custom User Avatar

    You need to replace "func swap(_ s: String, n: Int) -> String" with "func swap(_ s: String, _ n: Int) -> String". Then the error "type of expression is ambiguous without more context" will disappear

  • Custom User Avatar

    On Swift 5.3, no matter what the solution is, compiler gives out "error: type of expression is ambiguous without more context" for every single test case.

  • Default User Avatar

    It's not obvious from the description that the bits should be in the reversed order, how about an asymmetric example instead of 1001?

  • Custom User Avatar

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

  • Custom User Avatar

    number of random tests can be safely increased to ~100

  • Custom User Avatar

    do your random tests work? i get an output 'loll' should equal '' even though my function decode('loll') returns '' (e.g. if i put this case in the sample tests)

    also your random tests for decode just test for character combinations, they don't check any number input as well.

  • Custom User Avatar

    Hi,

    z should encode/decode with 2