0010【Edabit ★☆☆☆☆☆】Maximum Edge of a Triangle

【Edabit 算法 ★☆☆☆☆☆】Maximum Edge of a Triangle

algorithms math numbers

Instructions

Create a function that finds the maximum range of a triangle's third edge, where the side lengths are all integers.

Examples
javascript 复制代码
nextEdge(8, 10) // 17
nextEdge(5, 7) // 11
nextEdge(9, 2) // 10
Notes
  • (side1 + side2) - 1 = maximum range of third edge.
  • The side lengths of the triangle are positive integers.
  • Don't forget to return the result.
Solutions
javascript 复制代码
function nextEdge(side1, side2) {
    return side1 + side2 - 1;
}
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);
            }
        }
    }
})();

Test.assertEquals(nextEdge(5, 4), 8)
Test.assertEquals(nextEdge(8, 3), 10)
Test.assertEquals(nextEdge(7, 9), 15)
Test.assertEquals(nextEdge(10, 4), 13)
Test.assertEquals(nextEdge(7, 2), 8)
相关推荐
渣波2 分钟前
全栈开发的“影分身”之术(mock):别再手动造数据了,你的 CRUD 不配让我等!
前端·javascript
湖南天硕国产SSD2 分钟前
工业存储可靠性进阶:天硕工业固态硬盘动态温控与寿命优化技术实践
网络·数据库·算法·工业存储·天硕存储·工业固态硬盘
legend050709ComeON2 分钟前
常见面试题-leetcode
数据结构·算法·leetcode
Smilecoc12 分钟前
决策树(一):决策树基本原理
算法·决策树·机器学习
weixin_3077791314 分钟前
从工具到协作者:AI在后端研发中的流程重构与组织赋能
人工智能·后端·python·算法·自动化
爱吃生蚝的于勒17 分钟前
QT开发第三章——常用控件
linux·服务器·开发语言·前端·javascript·c++·qt
沉下去,苦磨练!24 分钟前
深度学习神经网络的搭建
人工智能·算法
xuankuxiaoyao31 分钟前
Axios-图书列表案例
开发语言·前端·javascript
meilindehuzi_a33 分钟前
深入理解 JavaScript 数据类型:从冯·诺依曼架构到八种数据类型
javascript
影寂ldy33 分钟前
C# 多播委托
前端·javascript·c#