about | help | code help+videos | done | prefs |
A "Magic Sunflower" is a square array of positive integers that is arranged so the sum of the integers in the two diagonals is the same. Numbers outside of the two diagonals are not used to determine this sum, but ALL numbers in the array MUST be positive. Your method should accept any size array of integers. You will return error codes indicating the specific error: -901 means that the array was not square. -850 means that there were negative numbers somewhere in the square array. -820 means that there were no negatives, but there were zeros somewhere in the square array. -99 means that the array met all the requirements EXCEPT the two diagonals did not have the same sum. However, if the array IS a "Magic Sunflower" you will return the sum of one of the diagonals. Look at the test data for examples. magicSunflowerAustralia([6, 5, 4, 7, 7, 7, 16, 4, 14]) → 27 magicSunflowerAustralia([20, 35, 18, 22, 7, 10, 14, 3, 1, 2, 30, 4, 32, 112, 5, 10]) → 70 magicSunflowerAustralia([5, 5, 5, 1, 5, 5, 1, 5, 5, 1, 5, 5, 1, 5, 5, 5]) → -99 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy