Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active October 14, 2020 07:09
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/c95de11e2004522c3e8d1bf318330ad3 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/c95de11e2004522c3e8d1bf318330ad3 to your computer and use it in GitHub Desktop.
Just PHP FUN 128.
<?php
# https://www.codewars.com/kata/5829ca646d02cd1a65000284 Coding Meetup #9 - Higher-Order Functions Series - Is the meetup age-diverse?
function is_age_diverse(array $a): bool {
$a = array_values(array_unique(array_map(function($x){ return floor($x['age']/10);}, $a)));
sort($a);
for($i = 1; $i <= 9; $i += 1) if(false === array_search($i,$a)) return false;
if(10 > $a[count($a) - 1]) return false;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment