Ad
  • Custom User Avatar

    new Void() in Java

    ??? The Java equivalent is null, like in C# and Javascript. The Void type in Java has no public constructor, so you can't call new Void() and you can't return an instance of Void. It's just there to represent the void keyword as something you can interact with.

  • Custom User Avatar

    In the execution I copy+pasted the header + log from for the wrong result, it was expecting false, which would have been correct for the arguments it was supposed to be passing according to the header. My function returned true, which was correct for the actual arguments it was given. Even if you don't get it to fail, you can see the arguments it's supposed to pass and the arguments it actually passes are different if you print the arguments.

  • Custom User Avatar

    Doing it in Typescript. The first random test consistently (EDIT: semi-consistently) fails and, going by console.log calls, it looks like it's because it's asserting the result of one set of inputs while actually calling the function with a different set.

    Where my solution begins with:

    export function comp(a: number[] | null, b: number[] | null): boolean
    {
        if(a == null || b == null || a.length != b.length)
            return false;
        
        console.log("");
        console.log("a: " + a);
        console.log("b: " + b);
        console.log("");
        ...
    }
    

    The first random test fails with expected true to equal false, where the first random test's header reads: (wrapped for readability)

    Testing for [26, 92, 76, 29, 46, 74, 16, 55, 22, 28, 92, 10, 99, 5, 73, 94, 16, 27, 7, 2, 94]
    and [676, 8464, 5776, 841, 2116, 5476, 256, 3025, 484, 784, 8464, 100, 9801, 25, 5329, 8836, 256, 729, 49, 4, 8836]
    

    but the console log reads:

    a: 52,26,2,66,16,91,52,13,18,100,54,47,35,82,89
    b: 2704,676,4,4356,256,8281,2704,169,324,10000,2916,2209,1225,6724,7921
    

    Every other test passes with my current solution.

    EDIT: Looking at the logs of the rest of the random tests, regardless of what the test header says they're testing, they all (except the first) have the log output:

    a: 0,1,1,2,4,10,15,32,39,60,63,67,77,78,85,86,93
    b: 0,1,1,4,16,100,225,1024,1521,3600,3969,4489,5929,6084,7225,7396,8649
    
  • Custom User Avatar

    The Swift tests are still broken.

    The sample tests fail by themselves independent of the solution code: https://i.imgur.com/qwh8jTm.png

    The "attempt" random tests expect the wrong results for "8.2M ohms" ( https://i.imgur.com/21Xarxu.png ) and "4.1M ohms". ( https://i.imgur.com/ppBHn61.png )

  • Custom User Avatar

    I did not mean to submit that ~_~ I was trying to get the "attempt" random tests to test with "8.2M ohms", which seems to test for the wrong answer. (At least in the Swift version)

  • Custom User Avatar

    Ah. I completed it for Swift. The tests given for swift require a different format from the tests for every other language.

  • Custom User Avatar

    If the string I provided, which is used as the example, matched the format of the strings actually passed in, it would be

    "01|15|59,1|47|6,01|17|20,1|32|34,2|3|17"

  • Custom User Avatar

    "01|15|59, 1|47|6, 01|17|20, 1|32|34, 2|3|17"

    The description suggests that times in the strings provided are separated by ", ", they're actually separated by ",".

  • Custom User Avatar

    #Note In Java there is no easy way with optional parameters so all three parameters will be given; the same in C# because, as of now, the used version is not known.

    In both Java and C#, this can be done easily with overloads:

    public static string Convert(double n)               { Convert(n, 0,        Math.PI); }
    public static string Convert(double n, int decimals) { Convert(n, decimals, Math.PI); } 
    
    public static string Convert(double n, int decimals, double nbase) {...}
    

    and C# (although not Java) supports default values using similar syntax to those used in the Python and Ruby versions of this kata:

    public static string Convert(double n, int decimals = 0, double nbase = Math.PI) {...}
    
  • Custom User Avatar
  • Custom User Avatar

    What are you talking about? The only overwriting I do there is in declaring constructors.

  • Custom User Avatar

    I decided to do this in Python as a generic solution using classes, just because. If I assign a new instance of my object to a variable at the same level as the function, the random tests seem to be trying to call that variable, and I get this error immediately after the first random test has completed: https://i.imgur.com/Zv65cUY.png (The variable was named "filter" and the class "SmileyFilter")

  • Custom User Avatar

    I like this challenge, but I don't like that it requires division by 0 to return 0 rather than NaN or infinity.

  • Custom User Avatar

    It was always drummed into me that you should absolutely never use float or double for currencies - it seems to me like the signature should really be (int, double, double, int).