6 kyu

Find unique number

208 of 207myjinxin2015

Description:

When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said

Description:

Give you a array arr that contains some numebers. Numbers can be positive,negative,integer or float. Only one of these numbers is unique. Find and return it.

Some examples:

findUnique([1,2,3,5,7]) === 2
Because only 2 is an even number, the other numbers are odd.

findUnique([2,4,6,8,9]) === 9
Because only 9 is an odd number

findUnique([2,-4,6,8]) === -4
Because only -4 is a negative number

findUnique([-2,-4,-6,8]) === 8
Because only 8 is a positive number

findUnique([2,4.4,6,8]) === 4.4
Because only 4.4 is a float number

findUnique([2.2,4.4,6.6,8]) === 8
Because only 8 is a integer number

findUnique([2,2,2,4]) === 4
Because only 4 has a diffrent value

Priority level: float/integer > positive/negative > odd/even > diffrent value

Some edge case:

findUnique([-2,-4,-6.6,8]) === -6.6  //not 8
Because Priority level float/integer > positive/negative

findUnique([-2,-4,-7, 8]) === 8  //not -7
Because Priority level positive/negative > odd/even

Note: All inputs will be an array. The array contains at least 3 element. Only one unique number in it. 0 will not appear, do not worry about it ;-)

Puzzles

Stats:

CreatedNov 9, 2016
PublishedNov 9, 2016
Warriors Trained696
Total Skips9
Total Code Submissions1234
Total Times Completed207
JavaScript Completions208
Total Stars27
% of votes with a positive feedback rating93% of 82
Total "Very Satisfied" Votes71
Total "Somewhat Satisfied" Votes10
Total "Not Satisfied" Votes1
Total Rank Assessments7
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • Voile Avatar
Ad