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
相关推荐
iCxhust3 小时前
c# U盘映像生成工具
开发语言·单片机·c#
yangzhi_emo3 小时前
ES6笔记2
开发语言·前端·javascript
董董灿是个攻城狮3 小时前
5分钟搞懂什么是窗口注意力?
算法
Dann Hiroaki4 小时前
笔记分享: 哈尔滨工业大学CS31002编译原理——02. 语法分析
笔记·算法
emplace_back4 小时前
C# 集合表达式和展开运算符 (..) 详解
开发语言·windows·c#
jz_ddk4 小时前
[学习] C语言数学库函数背后的故事:`double erf(double x)`
c语言·开发语言·学习
萧曵 丶4 小时前
Rust 所有权系统:深入浅出指南
开发语言·后端·rust
xiaolang_8616_wjl4 小时前
c++文字游戏_闯关打怪2.0(开源)
开发语言·c++·开源
收破烂的小熊猫~5 小时前
《Java修仙传:从凡胎到码帝》第四章:设计模式破万法
java·开发语言·设计模式