# Question 1 : Alien phone number There is a nearby planet whose nu...

## Question

Question 1 :
Alien phone number
There is a nearby planet whose number are formatted as “xxxx xxxx” where “x” is any numerical digit (0-9). Write a function that determines whether a given string is a valid alien phone number.

Constraint: you may not use RegExp.
Examples:
Alien_phone_number?(‘1234 5678’) => true
Alien_phone_number?(‘ar32 t19i’) => false
Alien_phone_number?(‘123 45678’) => false
Alien_phone_number?(‘12345678’) => false
Alien_phone_number?(‘1234 567’) => false
Alien_phone_number?(‘12345 12345’) => false

Question 2: **Pair Programming**
Ping Pong Filter
Imagine that we have a filter that goes through an array and removes every other element. When it reaches the final element it turns around and does the whole process again, this time going from the end to the start. It repeats this behavior until there is only one element left.

For example:
Given a starting array[1,2,3,4,5,6,7,8]
We start from the beginning and remove every other element (indicated with !)
[!1,2,!3,4,!5,6,!7,8] = [2,4,6,8]
Next we start from the end and remove every other element
[2,!4,6,!8] = [2,6]
Now we start from the beginning again and remove every other element
[!2, 6] =[6]
Write a method that takes an array of elements. It should return the only element that would remain after filtering the array in the manner described above.
Examples:
Ping_pong_filter([1,2,3,4,5,6,7,8]) => 6
Ping_pong_filter([1,2,3,4]) => 2
Ping_pong_filter([3,5,7,8,9,2]) => 8
Ping_pong_filter([”dog”,”cat”,”rabbit”,”hamster”, “monkey”,”tarantula”]) => “hamster”

Question 3:
Next Prime
Given an array of numbers, replace each prime number in the array with the next prime number, e.g. 7 is replaced by 11. Constraint: you may not use a library to find prime numbers.
Examples:
Next_prime([11,13,17]) => [13,17,19]
Next_prime([4,6,8,10]) => [4,6,8,10]
Next_prime([2,5,4,7]) => [3,7,4,11]

Question 4:
Five Sort
Write a function that receives an array of numbers as an argument. It should return the same array with the fives moved to the end the ordering of the other elements should remain unchanged

For example:
Nums = [1,5,3,5,5,2,3]
Sorted = five_sort(nums)
Sorted => [1,3,2,3,5,5,5]
Rules
You may not, at any time, create a new array
You are only permitted to use a ‘while’ loop
You are not permitted to call any methods on the array. Only the use of [], []=, and length are permitted.

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

function Alien_phone_number(number){

if (number.length === 9){

for (var i=0; i<number.length; i++){

if(i === 4){

if (number[i] != " "){
return false;
}

}else{

if (isNaN(number[i])){
return false;
}

}

}

return true;

}else{
return false;
}
}...

By purchasing this solution you'll be able to access the following files:
Solution.docx.

# 50% discount

Hours
Minutes
Seconds
\$30.00 \$15.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Computer Science - Other Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.