Ad
  • Custom User Avatar

    You are close to the answer, you can observe the conner cases, and search for Python boolean.

  • Custom User Avatar

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

  • Custom User Avatar
    1. It would be nice tell the user the quantity and price that results in incorrect output. Instead of this:

           XCTAssertEqual(mango(quantity: q, price: p), (q-(q/3))*p)
      

    Try this:

            XCTAssertEqual(mango(quantity: q, price: p), (q-(q/3))*p, "Incorrect output for quantity \(quantity) price: \(price)")
    

    Same on the fixed tests.

    Also (cosmetic issues):
    2) get rid of the //TODO comments at the top of the tests.
    3) Change testExample() to testFixed()

  • Custom User Avatar

    Thanks for the translation candidate.

    Cosmetic issues found during my review:

    1. Get rid of these comments at the start of the sample tests and full tests:
      // XCTest Spec Example:
      // TODO: replace with your own tests (TDD), these are just how-to examples to get you started

    2. Change testExample() to testFixed() (both in sample test and full tests)

    I normally like to give meaningful test failure output but I'm not sure if there's a better way to do it here given we're solving an infinite loop problem

  • Custom User Avatar

    Here's my Swift translation checklist, based on a moderator reviewing my stuff heavily:

    1. Rename function to lower camel case
    2. Include messaging in test asserts like this: XCTAssertEqual(sixToast(4), 2, "Incorrect answer for num = 4") (where num is the function parameter name)
    3. Include tests for low, high, and edge cases
    4. Change testExample to testSample
    5. Include random tests
    6. Shuffle random tests if possible
    7. Change test names. Should not be “example”. Full tests should not be named “sample”
    8. Remove TODO comments from tests
    9. Make initial solution compilable without errors (adding “return 0” for example
    10. If floating point, consider conversion to integers or use the XCTAssertEqual(converter(mpg: 36),12.74,accuracy: 0.01, "Incorrect answer for mpg: 36)")

    Minor stuff you should do for this translation:

    1. Rename function to lower camel case to conform to Swift programming best practices.

    2. Remove the 2-lines of //TODO sample comments from the top of the sample tests and full tests.

  • Custom User Avatar

    Please note that when a fork of your translation gets approved, then it's still you who gets the reward. So nothing lost here. So even if darrelroot's fork gets merged, you will get all the points (not many, but still :) )

  • Custom User Avatar

    Thank you very much!

    I'm new to this and wanted to test out writing my own translations. What a miss from me writing this one. Much appreciated!

  • Custom User Avatar

    Here's updated tests from my fork. Feel free to incorporate in yours since you wrote the original translation and appear to still be active:

    func testExample() {
        XCTAssertEqual(otherAngle(a:30, b:60), 90, "Incorrect result for a:30 b:60")
        XCTAssertEqual(otherAngle(a:60, b:60), 60, "Incorrect result for a:60 b:60")
        XCTAssertEqual(otherAngle(a:43, b:78), 59, "Incorrect result for a:43 b:78")
        XCTAssertEqual(otherAngle(a:10, b:20), 150, "Incorrect result for a:10 b:20")
    }
    
    func randomTest() {
        for _ in 1...100 {
          let a = Int.random(in:1...178)
          let degreesAvailableForB = 180 - a - 1;
          let b = Int.random(in:1...degreesAvailableForB)
          let c = 180-a-b
          
          XCTAssertEqual(otherAngle(a:a, b:b), c, "Incorrect result for a:\(a) b:\(b)")
        }
    }
    
  • Custom User Avatar

    Consider the random tests:

          let a = Int.random(in:1...175)
          let b = Int.random(in:1...180) - a
          let c = 180-a-b
    

    If the first random is 1, and the second random is 1, then angle b is 0 degrees.

    By comparison, the C translation lets the first angle range from 1 through 178, leaving 2 degrees for the 2nd and third angle.

  • Default User Avatar

    the sequence of all numbers from 1 to n

    ->

    clearly inclusive, no?

  • Custom User Avatar

    "A friend of mine takes the sequence of all numbers from 1 to n (where n > 0)."

    Inclusive or exclusive?

  • Custom User Avatar

    This is a nice problem, I am stuck with how to make my code faster... Anyone have any suggestions for me? Writing in swift

  • Custom User Avatar

    There is also a double space in the middle there.

  • Custom User Avatar

    I'm sorry, added to description there should be no whitespaces beginning or ending the string.

  • Custom User Avatar

    I have fixed the tests with replacing var to let.

    I haven't found katas being like this, if this is the case should I delete this one?

    I don't feel like there is a need to make the description only for swift but I'm new to this, give me feedback what to do, thanks!

  • Loading more items...