6 kyu

Onion array

215 of 549aweleshetu

Description:

An onion array is an array that satisfies the following condition for all values of j and k:

If all of the following are true:

  • j >= 0
  • k >= 0
  • j + k = array.length - 1
  • j != k

then:

  • a[j] + a[k] <= 10

Examples:

[1, 2, 19, 4, 5]   =>  true  (as 1+5 <= 10 and 2+4 <= 10)
[1, 2, 19, 4, 10]  =>  false (as 1+10 > 10)

Write a function named isOnionArray/IsOnionArray/is_onion_array() that returns true if its argument is an onion array and returns false if it is not.

Fundamentals

Stats:

CreatedSep 8, 2017
PublishedSep 8, 2017
Warriors Trained967
Total Skips26
Total Code Submissions3149
Total Times Completed549
JavaScript Completions215
C# Completions83
PHP Completions83
Python Completions201
Total Stars14
% of votes with a positive feedback rating88% of 178
Total "Very Satisfied" Votes144
Total "Somewhat Satisfied" Votes25
Total "Not Satisfied" Votes9
Total Rank Assessments13
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • aweleshetu Avatar
  • donaldsebleung Avatar
  • Voile Avatar
  • Souzooka Avatar
  • FArekkusu Avatar
  • hobovsky Avatar
Ad