#Code Challenge #9: June 7, 2017
Every week, we feature the type of brain-teasing question that might be asked in a full-stack developer’s job interview at places such as Google and Facebook.
This week’s challenge was reported to have been asked in interviews at Facebook:
###Basic Difficulty
Write a function,
primeNumberDetector
, that tests if a number,n
is a prime number.
- Function Name:
primeNumberDetector
- Input:
integer n
- Output:
boolean
:true
ifn
is a prime number elsefalse
. - Example:
primeNumberDetector(13) => True
#####Find out more about basic challenges.
###Intermediate difficulty
Write a function,
primeNumberPrinter
, that will print out all prime numbers in a given string.
- Function Name:
primeNumberPrinter
- Input: A single
string
- Output: An
integer array
of the prime numbers contained in the string - Example:
primeNumberPrinter("abc2134kd31")
, will output an array[2,13,3,3,31]
(in the order they appear in the string).
#####Find out more about intermediate challenges.
###Hard Difficulty
Write
primeNumberDetector
andprimeNumberPrinter
as efficiently as possible.
#####Find out more about hard challenges and Big O
Reply
to this thread with a link to your code on repl.it to participate! Don’t just submit your code, remember to explain
your solution, too! If you want to be considered as the winner, your function must
have the correct name
and provide output in the format specified
above, you also need to abide by our other simple rules.
The fine print:
Click the links to find out more about:
- the rules & how to participate in challenges
- how challenges are used as job interview questions
- why Codecademy runs challenges (and why they are formatted this way)
- more details about the challenges and why we think they are useful.
- find previous challenges (and see the past winners) in our Challenge Index