by cpglkg
<script><br>var arr=[5,10,15];<br><br><br>function ret(arr,width)<br>{<br> arr.sort(function( a,b){return a-b;});<br> var len = arr.length;<br> var temp = arr[0];<br> var w = null;<br> var h = null;<br> for(var i = 0; i < len; i )<BR> {<BR> if((temp i) != arr[i])<BR> {<BR> w = i;<BR> if (len % w != 0)<BR> false 반환;<BR> h = len/w;<BR> break;<BR> }<BR> }<BR> var r = 너비 - w;<BR> 온도 = r;<BR> for(var i = w; i < len; i )<BR> {<BR> if(arr[i] != temp i)<BR> {<BR> temp = r;< <BR> true를 반환합니다.<BR>}<BR>alert(ret(arr,6));<BR></script>
by 无殇
<script><br>varrows=6;<br>function ch(array){</div>array=array.sort(function(a,b){return a-b;})<br>var n ,c=0;<br>for(var i=1;i<array.length;i )<BR>if(array[i]-array[i-1]==1)<DIV class=code>c ;<BR>else<BR>break;<BR>if(array.length%(c 1)!=0)return false;<BR>for(var i=1;i<array.length;i )<BR>{<BR>n=array[i]-array[i-1];<BR>if(n!=1 && n c!=rows)<BR>false 반환;<BR>}<BR>true 반환;<BR> }<BR>경고(ch([1,2,3]))<BR>경고(ch([5,6,11,12,17,18,23,24]))<BR>경고(ch( [19,25,31]))<BR>alert(ch([1,2,3,4,7,8]))<BR></script>
작성: 秦皇也爱JS
<script><br> var arr = [5,10,15];</div> var width = 6; <br><br> arr = arr.sort(function(a,b){ return a-b});<br> var row = Math.ceil((arr[arr.length-1]-arr[0] 1) /width);<br> var col = Math.floor(arr.length / row);<div class="code">
<br> check();<br> function check(){<br> for(var i=0;i< ;arr.length-1;i ){<br> if(arr[i 1] - arr[i] !=1 && i%col!=col-1 || i%col==col-1 && arr[ i 1] - arr[i] != width-col 1){<br> alert(false);<br> return;<br> }<br> }<br> alert(true);<br> }<br> </script>