7 kyu
sum_eq_n?
257 of 256jastuccio
Description:
Define a method sum_eq_n? which takes an array of integers and an additional integer, n, as arguments and returns true if any two elements in the array of integers sum to n. An empty array should sum to zero by definition.
Examples:
sum_eq_n?([1, 2, 3, 4], 6) == true # 4 + 2 = 6
sum_eq_n?([1, 2, 3, 4], 8) == false # Not possible
sum_eq_n?([], 0) == true # An empty array should sum to 0
sum_eq_n?([], 1) == false # Not possible
I saw this on stackoverflow and thought it would make an interesting kata.
Arrays
Fundamentals
Similar Kata:
Stats:
Created | Jan 14, 2015 |
Published | Jan 14, 2015 |
Warriors Trained | 466 |
Total Skips | 61 |
Total Code Submissions | 979 |
Total Times Completed | 256 |
Ruby Completions | 257 |
Total Stars | 2 |
% of votes with a positive feedback rating | 86% of 74 |
Total "Very Satisfied" Votes | 59 |
Total "Somewhat Satisfied" Votes | 10 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 43 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 8 kyu |