MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/ghmkir/deleted_by_user/fqbfrek/?context=3
r/badcode • u/[deleted]
[deleted] — view deleted post
44 comments sorted by
View all comments
7
PHP 7.4: See https://3v4l.org/PQSYB
<?php function to_ascii_seven_segment( ... $numbers) { return implode("\n",array_map(fn($n)=>implode("\n",array_map(fn($r)=>join('',array_map(fn($d)=>substr( " _ _ _ _ _ _ _ _ ". " | | | _| _| |_| |_ |_ | |_| |_| ". " |_| | |_ _| | _| |_| | |_| _| " ,$r*44+4*(array_search($d,str_split(" 0123456789"))),4),str_split($n))),range(0,3))), $numbers)); } echo to_ascii_seven_segment( '1337', '7083170', '5318008', '53177187714' );
0 u/[deleted] May 11 '20 [deleted] — view deleted comment 3 u/joske79 May 17 '20 edited May 17 '20 :) My main goal was that the '0123456789' 7-segment 'font' was visible as-is in the code.Ofcourse, it could've been worse:function to_ascii_seven_segment( ... $numbers) { $g=fn($d)=>is_numeric($d)?hexdec(substr('00f59079d99ccded91fddd',$d+1<<1,2))<<1:0;$q=' |_'; $j=fn($c,$v,$s="\n")=>join($s,array_map($c,$v)); return @$j(fn($n)=>$j(fn($r)=>$j(fn($d)=> $q[0<($g($d)&1<<$r++)].$q[(0<($g($d)&1<<$r++))<<1].$q[0<($g($d)&1<<$r++)], str_split($n),''),range(0,9,3)),$numbers); }https://3v4l.org/899oJ
0
[deleted] — view deleted comment
3 u/joske79 May 17 '20 edited May 17 '20 :) My main goal was that the '0123456789' 7-segment 'font' was visible as-is in the code.Ofcourse, it could've been worse:function to_ascii_seven_segment( ... $numbers) { $g=fn($d)=>is_numeric($d)?hexdec(substr('00f59079d99ccded91fddd',$d+1<<1,2))<<1:0;$q=' |_'; $j=fn($c,$v,$s="\n")=>join($s,array_map($c,$v)); return @$j(fn($n)=>$j(fn($r)=>$j(fn($d)=> $q[0<($g($d)&1<<$r++)].$q[(0<($g($d)&1<<$r++))<<1].$q[0<($g($d)&1<<$r++)], str_split($n),''),range(0,9,3)),$numbers); }https://3v4l.org/899oJ
3
:) My main goal was that the '0123456789' 7-segment 'font' was visible as-is in the code.
Ofcourse, it could've been worse:
function to_ascii_seven_segment( ... $numbers) { $g=fn($d)=>is_numeric($d)?hexdec(substr('00f59079d99ccded91fddd',$d+1<<1,2))<<1:0;$q=' |_'; $j=fn($c,$v,$s="\n")=>join($s,array_map($c,$v)); return @$j(fn($n)=>$j(fn($r)=>$j(fn($d)=> $q[0<($g($d)&1<<$r++)].$q[(0<($g($d)&1<<$r++))<<1].$q[0<($g($d)&1<<$r++)], str_split($n),''),range(0,9,3)),$numbers); }
https://3v4l.org/899oJ
View all comments
7
u/joske79 May 11 '20
PHP 7.4: See https://3v4l.org/PQSYB