• Got stuck in between, but was fun to puzzle through. Great kata:)))

  • Hey guys!

    I need your help, I dont understand why, but this code doesn't work here, but perfectly works in browser.
    I am getting an error :

    TypeError: Cannot read property '1' of undefined
    at cakes
    at runTest
    at /home/codewarrior/index.js:52:5
    at begin
    at it
    at /home/codewarrior/index.js:51:3
    at /runner/frameworks/javascript/cw-2.js:152:11
    at Promise._execute
    at Promise._resolveFromExecutor
    at new Promise
    at describe
    at /home/codewarrior/index.js:45:5
    at /home/codewarrior/index.js:112:5
    at Object.handleError

    Why it's like that? Any thougths?

    function cakes(recipe, available) {
    let avaiableArr = Object.entries(available)
    let recipeArr = Object.entries(recipe)
    // console.log(avaiableArr)
    // console.log(recipeArr)
    if (avaiableArr.length >= recipeArr.length) {
    const sorted = (array) => array.sort(function (a, b) {
    if (a[0] < b[0]) {
    return -1;
    }
    if (a[0] > b[0]) {
    return 1;
    }
    return 0;
    })
    sorted(recipeArr)
    sorted(avaiableArr)
    console.log(avaiableArr)
    console.log(recipeArr)
    let portions = avaiableArr.map((element, index) => {
    return element[1] / recipeArr[index][1]
    });
    if (portions.some(el => el < 1)) {
    console.log(0)
    return 0;
    }
    console.log(Math.floor(Math.min(...portions)))
    return Math.floor(Math.min(...portions))
    }
    else {
    console.log(0)
    return 0
    }
    }

  • Wrong.

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

  • Нас учили так - "Прежде чем решить, задай себе вопрос, можно ли это решить через f строку, если да, то так и делай."

  • I have the same question. If the input is the PIN number as a string, then my code should work.

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

  • I used a bunch of if statements in the code, and it works everywhere but here. why isn't it working here? It is giving me an error that it expected "Jacob and Alex like this" for everything, but it also says that that is exactly what I submitted.
    So where's the erorr?

  • That makes sense - Thanks

  • Please use new python test framework.

  • I second natan: Study higher order functions (and maybe think of things like objects perhaps)

  • Old katas have bloated ranks. In other words, what's now a 7 could have passed for a 6 or even a 5.

  • Not sure why it was level 5 it seemed really straight-forward

  • It's not a kata issue, your solution is probably incorrect, but results in an assertion message which turns out to often confuse users.

    JUnit is trying to hint you that expected answer and your answer differ in a place denoted with square brackets. Your answer contains superfluous 's'.

  • Loading more items...