Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2. /*
  3. * Author: Wesley silva
  4. * Date: 06/08/2019
  5. */
  6.  
  7. function getDestination(){
  8. $starSystems = ['SIRIUS', 'LALANDE', 'PROCION', 'ALPHA CENTAURI', 'BARNARD'];
  9. $result = array_map(function ($starSystem) {
  10. $vowels = [1 => 'A', 2 => 'E', 3 => 'I', 5 => 'O', 8 => 'U'];
  11. $c = 0;
  12. $star = str_split($starSystem);
  13. for ($s = 0; $s < sizeof($star); $s++) {
  14. $vowel = $star[$s];
  15. if (in_array($vowel, $vowels)) {
  16. if ($c === 0) {
  17. $c = array_search($vowel, $vowels);
  18. } else {
  19. $c = $c * array_search($vowel, $vowels);
  20. }
  21. }
  22. }
  23. return $c;
  24. }, $starSystems);
  25. return $starSystems[array_search(75, $result)];
  26. }
  27. var_dump(getDestination());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement