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)
相关推荐
退休倒计时3 分钟前
【每日一题】LeetCode 17. 电话号码的字母组合 TypeScript
算法·leetcode·typescript
ssshooter9 分钟前
小程序分包页面报 "has not been registered yet" 的隐蔽根因:一个动态 import 拖垮整个分包
前端·javascript·微信小程序
粘稠的浆糊14 分钟前
[AtCoder - abc465_d ]X to Y题解
数据结构·c++·算法
鱼儿也有烦恼22 分钟前
数据结构合集
算法·algorithm
鹏多多30 分钟前
Web浏览器后台离线通知方案实现以及兼容指南
前端·javascript·vue.js
yangmu320332 分钟前
Vue3 响应式系统深度解析:从 Proxy 到依赖追踪
前端·javascript·vue.js
兰令水1 小时前
hot100【acm版】【2026.7.11/12打卡-java版本】
java·开发语言·数据结构·算法·职场和发展
Asize1 小时前
Node path 与 fs 模块:从回调地狱到 async await 的异步进化
javascript·node.js
研來如此1 小时前
图像文件大小
人工智能·算法·计算机视觉
千纸鹤安安1 小时前
开源 Agent 框架实战:用自然语言替代 Crontab 做运维
算法