Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. <?php
  2. /**
  3. * Correctness : 100%
  4. * Performance : not assesed
  5. * Complexity : ?
  6. * Task score : 100
  7. */
  8. function solution($N) {
  9. $b = decbin($N); // converting to binary
  10. $b = trim($b, 0); // removing trailing zeros
  11. $bP = explode('1', $b); // dividing parts containing zeros
  12. $l = array_map('strlen', $bP); // array mapping
  13. return max($l); // returing max lengthed array element which is the longest gap
  14. }
  15.  
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement