Skip to content

Commit 052fb97

Browse files
committed
Create index.js
1 parent 129575a commit 052fb97

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/index.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @type {import("chancellor")}
3+
*/
4+
let chancellor;
5+
6+
/**
7+
* @type {import("chancellor").flipcoin}
8+
*/
9+
let flipcoin;
10+
11+
12+
async function initialize () {
13+
if (chancellor) return;
14+
15+
chancellor = await import("chancellor");
16+
17+
flipcoin = chancellor.flipcoin;
18+
}
19+
20+
21+
async function run (input) {
22+
await initialize();
23+
24+
const x = input[0];
25+
const y = input[1];
26+
27+
let output = [ x, y ];
28+
29+
if (flipcoin()) {
30+
output[0] += y;
31+
output[1] *= 0.5;
32+
} else {
33+
output[0] *= 0.5;
34+
output[1] += x;
35+
}
36+
37+
return output;
38+
}
39+
40+
41+
module.exports = run;

0 commit comments

Comments
 (0)