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
相关推荐
如竟没有火炬9 分钟前
全排列——交换的思想
开发语言·数据结构·python·算法·leetcode·深度优先
嵌入式小李.man22 分钟前
C++第十三篇:继承
开发语言·c++
寂静山林22 分钟前
UVa 12526 Cellphone Typing
算法
Bryce李小白28 分钟前
Kotlin Flow 的使用
android·开发语言·kotlin
jarreyer1 小时前
python离线包安装方法总结
开发语言·python
李辰洋1 小时前
go tools安装
开发语言·后端·golang
wanfeng_091 小时前
go lang
开发语言·后端·golang
绛洞花主敏明1 小时前
go build -tags的其他用法
开发语言·后端·golang
ByteCraze1 小时前
秋招被问到的常见问题
开发语言·javascript·原型模式
码银1 小时前
【python】基于 生活方式与健康数据预测数据集(Lifestyle and Health Risk Prediction)的可视化练习,附数据集源文件。
开发语言·python·生活