Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Author: Wesley silva
- * Date: 06/08/2019
- */
- function getDestination(){
- $starSystems = ['SIRIUS', 'LALANDE', 'PROCION', 'ALPHA CENTAURI', 'BARNARD'];
- $result = array_map(function ($starSystem) {
- $vowels = [1 => 'A', 2 => 'E', 3 => 'I', 5 => 'O', 8 => 'U'];
- $c = 0;
- $star = str_split($starSystem);
- for ($s = 0; $s < sizeof($star); $s++) {
- $vowel = $star[$s];
- if (in_array($vowel, $vowels)) {
- if ($c === 0) {
- $c = array_search($vowel, $vowels);
- } else {
- $c = $c * array_search($vowel, $vowels);
- }
- }
- }
- return $c;
- }, $starSystems);
- return $starSystems[array_search(75, $result)];
- }
- var_dump(getDestination());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement