Advertisement
NozdrachevNN

Task 16+

Jul 10th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. $g = "707 423 584 293 572 62";
  3. $balGood = [ 1, 2, 3, 3, 4, 10 ];
  4. $e = "136 864 0 626 15 152 121";
  5. $balEvil = [ 1, 2, 2, 2, 3, 5, 10 ];
  6.  
  7. function result ($a, $b){
  8. $arr = explode (" ", $a);
  9. $i = 0;
  10. foreach ($arr as $key=>$value) {
  11. $i = $i + $value * $b [$key];
  12. }
  13. return $i;
  14. }
  15. $good = result ($g, $balGood);
  16. $evil = result ($e, $balEvil);
  17. if ($good > $evil) {
  18. print_r ("Battle Result: Good triumphs over Evil");
  19. }
  20. elseif ($good < $evil) {
  21. print_r ("Battle Result: Evil eradicates all trace of Good");
  22. }
  23. else {
  24. print_r ("Battle Result: No victor on this battle field");
  25. }
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement