25 lines
		
	
	
		
			580 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			580 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
$input = file_get_contents('input.txt');
 | 
						|
 | 
						|
const WIDTH = 25;
 | 
						|
const HEIGHT = 6;
 | 
						|
$area = WIDTH * HEIGHT;
 | 
						|
 | 
						|
$layers = array_map(static function($layer) {
 | 
						|
    return str_split($layer);
 | 
						|
}, str_split($input, $area));
 | 
						|
 | 
						|
usort($layers, function($layer_a, $layer_b) {
 | 
						|
    $a0 = array_count_values($layer_a)['0'];
 | 
						|
    $b0 = array_count_values($layer_b)['0'];
 | 
						|
    if ($a0 === $b0) {
 | 
						|
        return 0;
 | 
						|
    }
 | 
						|
    return  $a0 < $b0 ? -1 : 1 ;
 | 
						|
});
 | 
						|
 | 
						|
reset($layers);
 | 
						|
$fewest_0_layer = current($layers);
 | 
						|
 | 
						|
echo array_count_values($fewest_0_layer)['1'] * array_count_values($fewest_0_layer)['2']; |