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
相关推荐
Linux520小飞鱼1 小时前
F#语言的网络编程
开发语言·后端·golang
weixin_399264291 小时前
QT c++ 样式 设置 标签(QLabel)的渐变色美化
开发语言·c++·qt
吾当每日三饮五升4 小时前
C++单例模式跨DLL调用问题梳理
开发语言·c++·单例模式
猫武士水星4 小时前
C++ scanf
开发语言·c++
BinaryBardC5 小时前
Bash语言的数据类型
开发语言·后端·golang
Lang_xi_5 小时前
Bash Shell的操作环境
linux·开发语言·bash
Pandaconda5 小时前
【Golang 面试题】每日 3 题(二十一)
开发语言·笔记·后端·面试·职场和发展·golang·go
捕鲸叉5 小时前
QT自定义工具条渐变背景颜色一例
开发语言·前端·c++·qt
想要入门的程序猿5 小时前
Qt菜单栏、工具栏、状态栏(右键)
开发语言·数据库·qt
Elena_Lucky_baby6 小时前
在Vue3项目中使用svg-sprite-loader
开发语言·前端·javascript