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
相关推荐
朝朝辞暮i5 小时前
C++ 第 21 课:struct —— 把一组相关数据打包在一起
开发语言·c++·算法
青梅橘子皮5 小时前
Blue---二分算法(二分查找与二分答案)
算法
长河5 小时前
Java的GC(垃圾回收)中,标记无用对象的核心方法是可达性分析算法
java·jvm·算法
月光船幽幽5 小时前
加性偏移外推提升参数识别可靠性
python·算法
SHARK_pssm5 小时前
【C++——类和对象(下)】
开发语言·c++·经验分享·笔记
凯哥Java5 小时前
写代码怎么避免逻辑漏洞?
java·开发语言·人工智能·自动化
Ivanqhz6 小时前
层归一化、残差、前馈网络与激活函数简述
服务器·数据库·人工智能·深度学习·算法
Ai-_Man6 小时前
您您这可以把Dola的多个会话比如说。左侧的多个会话一次性导出吗?不是单条会话里面的多次会对话。用AI导出鸭,答案是可以的
开发语言·前端·人工智能·小程序
Java后端的Ai之路6 小时前
Python进阶探索23 - Python中的Time与Datetime模块
开发语言·数据库·python·datetime·time
沫璃染墨6 小时前
《从零入门Linux系统篇(五十四):线程篇·七——互斥锁底层原理:从原子交换到线程竞争与锁实现》
linux·运维·服务器·开发语言·c++·驱动开发·系统架构