Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active October 1, 2020 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/8a903f3cfe02c2818edef6c2bc4e5431 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/8a903f3cfe02c2818edef6c2bc4e5431 to your computer and use it in GitHub Desktop.
Just PHP FUN 117.
<?php
# https://www.codewars.com/kata/526233aefd4764272800036f Matrix Addition.
function matrix_addition(array $a, array $b): array {
$size = count($a); $answer = [];
for($i = 0; $i < $size; $i += 1){
$zip = array_map(null,$a[$i],$b[$i]);
$answer[] = array_map(function($x){ return $x[0] + $x[1];}, $zip);
}
return $answer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment