"HR30 Day 11: 2D Arrays"의 두 판 사이의 차이

(새 문서: ==개요== ;<nowiki>Day 11: 2D Arrays</nowiki> * https://www.hackerrank.com/challenges/30-2d-arrays/problem {{HR30 헤더}} {{HR30 10-19}} |} ==PHP== <source lang='php'> <?php $stdi...)
 
23번째 줄: 23번째 줄:
             + $arr[$i][$j]
             + $arr[$i][$j]
             + $arr[$i+1][$j-1] + $arr[$i+1][$j] + $arr[$i+1][$j+1];
             + $arr[$i+1][$j-1] + $arr[$i+1][$j] + $arr[$i+1][$j+1];
        //echo $sum . " ";
         if( $sum > $max ) $max = $sum;
         if( $sum > $max ) $max = $sum;
     }
     }
    //echo "\n"; 
}
}
echo $max;
echo $max;
</source>
</source>

2018년 8월 9일 (목) 20:12 판

1 개요

Day 11: 2D Arrays
해커랭크 30 Days of Code
문제 풀이
10-19 Day e
HR30 Day 10: Binary Numbers

HR30 Day 11: 2D Arrays

HR30 Day 12: Inheritance

HR30 Day 13: Abstract Classes

HR30 Day 14: Scope

HR30 Day 15: Linked List

HR30 Day 16: Exceptions - String to Integer

HR30 Day 17: More Exceptions

HR30 Day 18: Queues and Stacks

HR30 Day 19: Interfaces

2 PHP

<?php
$stdin = fopen("php://stdin", "r");
$arr = array();
for ($i = 0; $i < 6; $i++) {
    fscanf($stdin, "%[^\n]", $arr_temp);
    $arr[] = array_map('intval', preg_split('/ /', $arr_temp, -1, PREG_SPLIT_NO_EMPTY));
}
fclose($stdin);
$max = -100;
for($i=1; $i<count($arr)-1; $i++) {
    for($j=1; $j<count($arr[0])-1; $j++) {
        $sum = $arr[$i-1][$j-1] + $arr[$i-1][$j] + $arr[$i-1][$j+1]
            + $arr[$i][$j]
            + $arr[$i+1][$j-1] + $arr[$i+1][$j] + $arr[$i+1][$j+1];
        if( $sum > $max ) $max = $sum;
    }
}
echo $max;
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}