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)
相关推荐
king王一帅2 小时前
Incremark Solid 版本上线:Vue/React/Svelte/Solid 四大框架,统一体验
前端·javascript·人工智能
C雨后彩虹4 小时前
任务最优调度
java·数据结构·算法·华为·面试
少林码僧6 小时前
2.31 机器学习神器项目实战:如何在真实项目中应用XGBoost等算法
人工智能·python·算法·机器学习·ai·数据挖掘
钱彬 (Qian Bin)6 小时前
项目实践15—全球证件智能识别系统(切换为Qwen3-VL-8B-Instruct图文多模态大模型)
人工智能·算法·机器学习·多模态·全球证件识别
Niuguangshuo7 小时前
EM算法详解:解密“鸡生蛋“的机器学习困局
算法·机器学习·概率论
a3158238067 小时前
Android 大图显示策略优化显示(一)
android·算法·图片加载·大图片
一条大祥脚7 小时前
26.1.9 轮廓线dp 状压最短路 构造
数据结构·c++·算法
鲨莎分不晴7 小时前
反向传播的数学本质:链式法则与动态规划的完美共舞
算法·动态规划
sonadorje7 小时前
逻辑回归中的条件概率
算法·机器学习·逻辑回归
cici158748 小时前
基于Pan-Tompkins算法的ECG信号HRV提取方案
算法