cpglkg 作成者
<script><br>var arr=[5,10,15];<br><br><br>function rect(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> return false;<BR> h = len/w;<BR> break;<BR> }<BR> }<BR> var r = width - <BR> 温度= r;<BR> for(var i = w; i < len; i )<BR> {<BR> if(arr[i] != temp i)<BR> {<BR> temp = r;<BR> if(arr[i] != temp i)<BR> {<BR> return false;<BR> }<BR> }<BR> }<br><br> true を返します;<BR>}<BR>alert(rect(arr,6));<BR></script>
by 無殇
<script><br>var rows=6;<br>function ch(array){<br>array=array.sort(function(a,b){return a-b;})<br>var n ,c=0;<br>for(var i=1;i<array.length>if(array[i]-array[i-1]==1)<br>c ;<br>else<br>break;<br>if(array.length%(c 1)!=0)return false;<br>for(var i=1;i<array.length>{<br>n=array[i]-array[i-1];<br>if(n!=1 && n c!=rows)<br>return false;<br>}<br>return true;<br> }<br>alert(ch([1,2,3]))<br>alert(ch([5,6,11,12,17,18,23,24]))<br>alert(ch( [19,25,31]))<br>alert(ch([1,2,3,4,7,8]))<br></script>
by 秦皇也爱JS
<script><br> var arr = [5,10,15];<br> 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> varcol = Math.floor(arr.length / row);<br><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>