Prime or not. [Hard mode] JK
Description:
NOTE FOR JS USERS:
the function called basics is just for testing and serves no purpose , don't try calling it , unless you wish to waste bytes.. your code goes inside the `P` function.
Challenge :
Given an array of numbers in the range of 0 to Infinity
, Check whether all of them are primes or not.
Input :
An array of numbers
Output :
The array with every element replaced by one of these :
-1 -----> if 0 , 1
1 -----> If it is a prime number greater than 1
the highest factor -----> if that number is not prime
Return either -1 (0 , 1) , 1 (for primes >= 2) or the highest factor of given number (for non-primes)
Examples :
[1 , 2 , 3 , 4 , 10 , 11 ,13] ---> [ -1, 1, 1, 2, 5, 1, 1 ]
[100 , 200 , 231321 , 12312 , 0 , 111381209 , 123123] ---> [ 50, 100, 77107, 6156, -1, 1, 41041 ]
Note :
Input will always be valid. i.e : It will consist only of numbers and decimals are not tested for. The array can be empty return the empty array if that is the casess
Restriction :
1).This is code-golf so char limits :
JavaScript : Less than or equal to 45 (Still hellishly large if you ask me. Will probably reduce to 40 or lil less)
Python : Less than or equal to 65
2). No more than one line
Reason :
I am interested in seeing all sorts of solution and would like to see users beat my score (which a lot of people most definitely will)
Similar Kata:
Stats:
Created | May 2, 2018 |
Warriors Trained | 132 |
Total Skips | 28 |
Total Code Submissions | 242 |
Total Times Completed | 20 |
JavaScript Completions | 10 |
Python Completions | 11 |
Total Stars | 0 |
% of votes with a positive feedback rating | 63% of 15 |
Total "Very Satisfied" Votes | 9 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 13 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 1 kyu |
Lowest Assessed Rank | 6 kyu |