You need to sign in or sign up before continuing.×
5 kyu

Bit calculator

1,442 of 2,110riomus
Description
Loading description...
Bits
Mathematics
Algorithms
  • Please sign in or sign up to leave a comment.
  • Jaarabytes Avatar

    great kata, viva to the author!

  • user8436785 Avatar

    anticheat can be bypassed trivially.

  • FArekkusu Avatar

    The sample and fixed tests are still using Test.expect.

    Also, the random tests could do with rewriting into a loop instead of having the same 3 lines copy-pasted 7 times.

  • dinglemouse Avatar

    console.log fails somehow because Math.max disabled??

    TypeError: Math.max is not a function
        at formatArray
        at formatValue
        at inspect
        at exports.format
        at Console.log
        at calculate
            at begin
        at it
            at /runner/frameworks/javascript/cw-2.js:159:11
        at Promise._execute
        at Promise._resolveFromExecutor
        at new Promise
        at describe
        at [eval]:39:21
    
  • Voile Avatar

    This comment has been hidden.

  • emgordon154 Avatar

    this is weird... my solution that works in Node v6.11.0 throws an error in Node v6.11.0/Babel because floor is undefined (my solution doesn't use Math.floor). perhaps Babel shouldn't be offered for this kata?

  • khanstan Avatar

    This comment has been hidden.

  • mikalai-sauchanka Avatar

    Number.parseInt is enabled

  • StandishMan25 Avatar

    This comment has been hidden.

  • user5036852 Avatar

    I would like to translate this kata into C#.

    Are you still online?

  • crashOverride Avatar

    That was a nice kata. Thanks!

    Although you probably should block Number.parserInt() as well. I've managed to finish it, second time around, just using that function.

    HTH.

  • robhol Avatar

    Why are the test functions here different from the ones in all the other kata?

  • user4386369 Avatar

    Is ~~ also disabled?

  • wthit56 Avatar

    The description implies there could be more than two bit strings to add together. I wrote mine to cater to that, but you might want to add some tests for those cases.

  • osuushi Avatar

    Is there any particular reason you left Math.pow enabled? You can pretty easily solve this problem without any Math functions whatsoever.

  • mweiss Avatar

    I think you should revise the text and name of the function. Here's some revised text:

    Write a function named sumBinary which takes as input two binary numbers represented as strings, and returns the sum as a number.

    For example:

    Test.expect(sumBinary("10","10")==4); Test.expect(sumBinary("10","0")==2); Test.expect(sumBinary("101","10")==7);

    Some math functions are disabled, as well as parseInt.

    The following Math functions are enabled: pow, round, random

  • laoris Avatar

    For parseInt and the Math functions that are disabled, it wouldn't hurt to disable them by replacing them with a function that throws an error message—something like:

    parseInt = function() {
        throw 'parseInt is disabled'
    };
    

    Then the test output would say "parseInt is disabled" instead of "object is not a function" if someone tries to use those functions.

  • rrowland Avatar

    The test errors were non-descript. I had to console.log to compare what was being passed to what was expected. Probably my fault, but it also took me a couple minutes to realize I was getting errors because parseInt was disabled. Other than that, it's a nice little Kata.

  • thisFeeling Avatar

    were you thinking about adding negative numbers ? it would be fun :)