Check if number can be displayed using seven segment led | Pre - computed values of segment used by digit 0 to 9. ; Check if it is possible to display the number ; Finding sum of the segments used by each digit of the number ; Driver Code ; Function call to print required answer
< ? php $ seg = array ( 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ) ; function LedRequired ( $ s , $ led ) { $ count = 0 ; global $ seg ; for ( $ i = 0 ; $ i < strlen ( $ s ) ; ++ $ i ) { $ count += $ seg [ ord ( $ s [ $ i ] ) - 48 ] ; } if ( $ count <= $ led ) return " YES " ; else return " NO " ; } $ S = "123456789" ; $ led = 20 ; echo LedRequired ( $ S , $ led ) ; ? >