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
相关推荐
wan5555cn2 分钟前
中国启用WPS格式进行国际交流:政策分析与影响评估
数据库·人工智能·笔记·深度学习·算法·wps
AndrewHZ5 分钟前
【图像处理基石】图像形态学处理:从基础运算到工业级应用实践
图像处理·python·opencv·算法·计算机视觉·cv·形态学处理
wjs20246 分钟前
ionic 列表:详解移动端UI设计中的列表组件
开发语言
仰泳的熊猫9 分钟前
LeetCode:1905. 统计子岛屿
数据结构·c++·算法·leetcode
Lear14 分钟前
【链表】LeetCode 206.反转链表
算法
Lear17 分钟前
【链表】LeetCode 24.两两交换链表中的节点
算法
xiaoxiangwendao23 分钟前
[26] 删除排序数组中的重复项
算法
洲覆26 分钟前
SQL 性能优化:出现 sql 比较慢怎么办?
开发语言·数据库·sql·mysql
熊小猿27 分钟前
如何在 Spring Boot 项目中使用 @Slf4j 注解结合 Logback 进行系统日志管理
java·开发语言·spring boot
THGML43 分钟前
排序算法解析
数据结构·算法·排序算法