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)
相关推荐
浩星21 分钟前
react的框架UmiJs(五米)
前端·javascript·react.js
Niyy_3 小时前
前端一个工程构建多个项目,记录一次工程搭建
前端·javascript
cynicme3 小时前
力扣3228——将 1 移动到末尾的最大操作次数
算法·leetcode
熬了夜的程序员3 小时前
【LeetCode】109. 有序链表转换二叉搜索树
数据结构·算法·leetcode·链表·职场和发展·深度优先
随意起个昵称4 小时前
【递归】二进制字符串中的第K位
c++·算法
快乐非自愿4 小时前
常用设计模式:工厂方法模式
javascript·设计模式·工厂方法模式
mjhcsp4 小时前
C++ 循环结构:控制程序重复执行的核心机制
开发语言·c++·算法
立志成为大牛的小牛4 小时前
数据结构——四十一、分块查找(索引顺序查找)(王道408)
数据结构·学习·程序人生·考研·算法
十年磨一剑~4 小时前
html+js开发一个测试工具
javascript·css·html
xier_ran5 小时前
深度学习:RMSprop 优化算法详解
人工智能·深度学习·算法