Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Created August 10, 2020 15:40
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/cc253b1548ec61aeca773df791e13b6b to your computer and use it in GitHub Desktop.
Save lbvf50mobile/cc253b1548ec61aeca773df791e13b6b to your computer and use it in GitHub Desktop.
Just PHP FUN 072.
<?php
# https://www.codewars.com/kata/54b42f9314d9229fd6000d9c Duplicate Encoder.
function duplicate_encode($word){
$w = strtolower($word); $hsh = count_chars($w,1);
return implode(array_map(function($x) use ($hsh){ return 1 == $hsh[ord($x)] ? "(" : ")";}, str_split($w)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment