0068【Edabit ★☆☆☆☆☆】I‘d Like a New Shade of Blue, Please

0068【Edabit ★☆☆☆☆☆】I'd Like a New Shade of Blue, Please

math numbers

Instructions

I have a bucket containing an amount of navy blue paint and I'd like to paint as many walls as possible. Create a function that returns the number of complete walls that I can paint, before I need to head to the shops to buy more.

  • n is the number of square meters I can paint.
  • w and h are the widths and heights of a single wall in meters.
Examples
javascript 复制代码
howManyWalls(100, 4, 5) // 5
howManyWalls(10, 15, 12) // 0
howManyWalls(41, 3, 6) // 2
Notes
  • Don't count a wall if I don't manage to finish painting all of it before I run out of paint.
  • All walls will have the same dimensions.
  • All numbers will be positive integers.
Solutions
javascript 复制代码
function howManyWalls(n, w, h) {
	return Math.floor(n/(w*h));
}
TestCases
javascript 复制代码
let Test = (function(){
    return {
        assertEquals:function(actual,expected){
            if(actual !== expected){
                let errorMsg = `actual is ${actual},${expected} is expected`;
                throw new Error(errorMsg);
            }
        },
        assertSimilar:function(actual,expected){
            if(actual.length != expected.length){
                throw new Error(`length is not equals, ${actual},${expected}`);
            }
            for(let a of actual){
                if(!expected.includes(a)){
                    throw new Error(`missing ${a}`);
                }
            }
        }
    }
})();
Test.assertEquals(howManyWalls(100, 4, 5), 5)
Test.assertEquals(howManyWalls(10, 15, 12), 0)
Test.assertEquals(howManyWalls(41, 3, 6), 2)
Test.assertEquals(howManyWalls(50, 11, 5), 0)
Test.assertEquals(howManyWalls(1, 1, 1), 1)

// Author: Joshua Señoron
相关推荐
小冷coding1 天前
【Java】遇到微服务接口报错导致系统部分挂掉时,需要快速响应并恢复,应该怎么做呢?如果支付服务出现异常如何快速处理呢?
java·开发语言·微服务
星火开发设计1 天前
二维数组:矩阵存储与多维数组的内存布局
开发语言·c++·人工智能·算法·矩阵·函数·知识
夜勤月1 天前
彻底终结内存泄漏与悬挂指针:深度实战 C++ 智能指针底层原理与自定义内存池,打造稳如泰山的系统基石
开发语言·c++
HeisenbergWDG1 天前
线程实现runnable和callable接口
java·开发语言
少控科技1 天前
QT新手日记028 QT-QML所有类型
开发语言·qt
丨康有为丨1 天前
算法时间复杂度和空间复杂度
算法
HarmonLTS1 天前
Python人工智能深度开发:技术体系、核心实践与工程化落地
开发语言·人工智能·python·算法
丁一郎学编程1 天前
测试开发面经
java·开发语言
wjs20241 天前
TypeScript 命名空间
开发语言
a程序小傲1 天前
京东Java面试被问:RPC调用的熔断降级和自适应限流
java·开发语言·算法·面试·职场和发展·rpc·边缘计算