Write a funtion named nthplanet which takes name of the planet as input string and provides the position of the planet, starting from Mercury at 1st position and Neptune at 8th , as output.(For those who are sad because I ignored Pluto, Pluto is considered as Dwarf planet by IAU)
If
x = 'Earth'
then
nthplanet(x)
gives
3
Please have a look at the Testsuite before you begin
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers30
Suggested Problems
-
How to find the position of an element in a vector without using the find function
2815 Solvers
-
Project Euler: Problem 2, Sum of even Fibonacci
2841 Solvers
-
Deleting an element in a matrix
491 Solvers
-
Converter temp 0 to 200 degree C to 4 to 20mA
115 Solvers
-
140 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Amar,
I think you have the order of the planets wrong in the test suite. Mars is #4, and #2 is Venus (which is missing from your list).
Thanks william, edited it.