快算24在這裡驗算

遊戲音樂影視動漫
Post Reply
ejsoon
Site Admin
Posts: 3697
Joined: 2016 Jan 10, 22:15

快算24在這裡驗算

Post by ejsoon » 2018 Aug 29, 10:14


ejsoon
Site Admin
Posts: 3697
Joined: 2016 Jan 10, 22:15

快算24經典題

Post by ejsoon » 2018 Sep 14, 15:02

5,8,9,13
5,5,5,12
2,2,10,11

ejsoon
Site Admin
Posts: 3697
Joined: 2016 Jan 10, 22:15

Re: 快算24在這裡驗算

Post by ejsoon » 2018 Sep 19, 12:27

自製24點和猜數字

難點:JS數組亂序

Code: Select all

function sortNumber(a,b) {
 return Math.random() - 0.5; 
} 
var arr = arr=[9,3,1,2,5,8,4,7,6,0]; 
arr.sort(sortNumber);

Code: Select all

function shuffle(arr) {
  var i = arr.length, t, j;
  while (i) {
    j = Math.floor(Math.random() * i--);
    t = arr[i];
    arr[i] = arr[j];
    arr[j] = t;
  }
}
國外https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array

還要做:
24點:給出解答或證明無解(這個可以不做,因爲上面的網站已經做好了)
猜數字:評分

Post Reply