プログラミングのお題スレ Part18
(ID:yG/yQHuOのみ表示中)
戻る
397デフォルトの名無しさん [sage]

AAS

NG

jsインタラクティブ入力に弱い

2020/08/29(土)22:51:06 yG/yQHuO.net


398デフォルトの名無しさん

AAS

NG

>>391

https://repl.it/@vip0/bullet#index.js

// 0-5
const rand6 = () => Math.floor(Math.random() * 6);

const gun = (() => {
let pos = 0;
const shuffle = () => (pos = rand6());
shuffle();
const shut = () => pos-- === -1
return { shuffle, pos, shut }
})()

// mock 1/2 rand
const readDoShuffleAsync = () => {
const y = Math.random() >= 0.5
console.log(y ? "y" : "n")
return y
}

let i = 1;
while (true) {
console.log("リボルバーを回しますか?");
if (readDoShuffleAsync()) gun.shuffle()
const bomb = gun.shut();
console.log(`${i}回目: ${bomb ? "バーン!" : "不発"}`);
i++;
if (bomb) break
[全て表示]

2020/08/29(土)23:12:55 yG/yQHuO.net


400デフォルトの名無しさん [sage]

AAS

NG

swift playgroundとかjestのinlineSnapshotみたいな感じか
使うときがあるか微妙

2020/08/29(土)23:41:03.13(yG/yQHuO.net)


戻る
ver.151005sp