Ad
  • Default User Avatar

    this kata is specific to C, it does not make sense in most other languages where arrays simply have a length property.

  • Custom User Avatar

    It's also funny you are able to tell me I need to write a complete description of the problem I have with your kata, while the exact issue with the kata is "there is no description at all". Try following your own advise maybe ..

  • Custom User Avatar

    What else is there to say? You have not provided any description of the problem.

  • Custom User Avatar

    ok, you've been warned.

  • Default User Avatar

    Every character is written by me after careful thought, kata has been rigorously tested many times before release, there is no problem with my code, there is only a problem with your code!

  • Custom User Avatar

    Have you actually done the calculation by hand?

    90 second + 0.5 min (30 second) = 120 second (2 minutes).

    If you can't even do the calculation by hand and insist whatever """code""" that you wrote is correct, I suggest replacing you with ChatGPT that can also write code that semi-work.

  • Default User Avatar

    @Blind4Basic No,you code is have some wrong.

    using mycode:

    addTime("90 sec","0.5 min","minute")
    1.5
    
  • Custom User Avatar
    • first example test is wrong, it's not my code
    • ofc my code is wrong, because I followed the specs of the description stating that the output format is only second or minute. Which is wrong

    And I still cannot read messages if you put a spoiler flag on them...

  • Default User Avatar

    See!

    addTime("1045312318272019 sec","104531231827.2019 min","hour")
    292106720050.45526
    addTime("104531231827.2019 min","1045312318272019 sec","hour")
    292106720050.45526
    
  • Default User Avatar
    function addTime(time1, time2, format) {
      const timeInSeconds = convertToSeconds(time1) + convertToSeconds(time2);
    
      if (format === "second") {
        return timeInSeconds;
      } else if (format === "minute") {
        return timeInSeconds / 60;
      } else if (format === "hour") {
        return timeInSeconds / 3600;
      } else if (format === "day") {
        return timeInSeconds / (3600 * 24);
      } else {
        return "Invalid format";
      }
    }
    
    function convertToSeconds(time) {
      const [value, unit] = time.split(" ");
      if (unit === "sec") {
        return parseInt(value);
      } else if (unit === "min") {
        return parseInt(value) * 60;
      } else if (unit === "hour") {
        return parseInt(value) * 3600;
      } else if (unit === "day") {
        return parseInt(value) * 86400;
      }
    }
    
  • Default User Avatar

    There is something wrong with your code, using my code you can pass the

  • Custom User Avatar

    oops, I didn't check what was the problem (it's the same as the last one, yes)

  • Custom User Avatar

    The second case is not wrong. The first one definitely is.

  • Custom User Avatar
    assert.strictEqual(addTime("90 sec","0.5 min","minute"), 1.5);  => wrong
    assert.strictEqual(addTime("1 hour","1380 min","day"), 1);      => wrong
    assert.strictEqual(addTime("120 min","60 sec","hour"), 2.0166666666666666);
                                                  ^^^^^=> goes against specifications
    

    I suggest you get your previous kata right before trying to author more of them.

    Thx

  • Custom User Avatar
      it("Big Number Test", function() {
        assert.strictEqual(addTime("1234567890000000000 hour","9876543210000000 day","second"), 5.297777737344e+21);
        assert.strictEqual(addTime("1045312318272019 sec","104531231827.2019 min","hour"), 292106720050.45526);
        assert.strictEqual(addTime("12345678987654321 day","30000000000 min","minute"), 17777777772222220000);
      });
    

    Please no. These numbers aren't exact in any way. They're subject to floating point errors, which means their values can change just by changing the order of calculation. See this

  • Loading more items...