本文主要是介绍【Edabit 算法 ★☆☆☆☆☆】 Basketball Points,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
【Edabit 算法 ★☆☆☆☆☆】 Basketball Points
language_fundamentals
math
numbers
Instructions
You are counting points for a basketball game, given the amount of 2-pointers scored and 3-pointers scored, find the final points for the team and return that value.
Examples
points(1, 1) // 5
points(7, 5) // 29
points(38, 8) // 100
Notes
- N/A
Solutions
function points(twoPointers, threePointers) {return twoPointers * 2 + threePointers * 3 ;
}
TestCases
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(points(1, 1), 5)
Test.assertEquals(points(1, 2), 8)
Test.assertEquals(points(2, 1), 7)
Test.assertEquals(points(2, 2), 10)
Test.assertEquals(points(69, 420), 1398)
这篇关于【Edabit 算法 ★☆☆☆☆☆】 Basketball Points的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!