In a Numberphile video on evil primes, Tony Padilla introduced the “Jesus prime” 105,192,119, which is formed by concatenating the positions of the letters of ‘Jesus’ in the English alphabet: 10, 5, 19, 21, 19. In general, a prime word could be defined as a word such that the number formed by concatenating the positions of the letters in the alphabet is prime.
Write a function that takes a string and identifies prime words. It should delete apostrophes and hyphens (e.g. “don’t” = “dont”, “un-ionized” = “unionized”) and treat other punctuation as spaces. The function should return an array of 0’s and 1’s.
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers18
Suggested Problems
-
Remove all the words that end with "ain"
2654 Solvers
-
Project Euler: Problem 3, Largest prime factor
1790 Solvers
-
Project Euler: Problem 10, Sum of Primes
2093 Solvers
-
Getting the indices from a vector
11876 Solvers
-
Put two time series onto the same time basis
350 Solvers
More from this Author323
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Chris,
In test suite problem 25, there seems to be an issue with the question mark after 'Africa'. The word Africa itself is a prime word, but the solution marks it as non-prime. Since the question mark is usually considered punctuation, I treated it as a space.
Thanks William. I fixed the test (and my own code).