The Pyramid Of King Djoser
Здравейте,
Някой ако има време, ще може ли да ми пише защо тази задача в VS Code ми дава верни отговори, а в judge първите два теста не минават и ми дава 75 точки. https://pastebin.com/Efxn6sfr
Благодаря предварително.
Здравейте,
Някой ако има време, ще може ли да ми пише защо тази задача в VS Code ми дава верни отговори, а в judge първите два теста не минават и ми дава 75 точки. https://pastebin.com/Efxn6sfr
Благодаря предварително.
Try to use the following case pyramid(1, 1);.
Your code should return:
Stone required: 0
Marble required: 0
Lapis Lazuli required: 0
Gold required: 1
Final pyramid height: 1
but instead prints:
Stone required: 0
Marble required: 0
Lapis Lazuli required: 0
Gold required: 0
Final pyramid height: 1
In the assignment it says: "and yellow steps are made entirely out of gold (top-most step)". So this is probably were the tests fail.
Best,
Code (100%)
function solve(baseSide, blockHeight) {
    baseSide = Number(baseSide);
    blockHeight = Number(blockHeight);
    let floor = 0;
    let stone = 0;
    let marble = 0;
    let lapis = 0;
    let gold = 0;
    while (baseSide > 1) {
        let totalBlocks = (baseSide * baseSide * blockHeight);
        let innerBlocks = ((baseSide - 2) * (baseSide - 2)) * blockHeight;
        let outerBlocks = totalBlocks - innerBlocks;
        if (baseSide - 2 === 0) {
            break;
        }
        floor++;
        baseSide -= 2;
        if (floor % 5 === 0) {
            lapis += outerBlocks;
            stone += innerBlocks;
        } else {
            marble += outerBlocks;
            stone += innerBlocks;
        }
    }
    floor++;
    height = Math.floor(floor * blockHeight);
    gold += Math.ceil(baseSide * baseSide * blockHeight);
    console.log(`Stone required: ${Math.ceil(stone)}`);
    console.log(`Marble required: ${Math.ceil(marble)}`);
    console.log(`Lapis Lazuli required: ${Math.ceil(lapis)}`);
    console.log(`Gold required: ${gold}`);
    console.log(`Final pyramid height: ${height}`);
}