This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
#SingleInstance force | |
; -------------------------------------------------------------- | |
; NOTES | |
; -------------------------------------------------------------- | |
; ! = ALT | |
; ^ = CTRL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Output: | |
Pick 1 winnings per game: -0.499308 | |
Pick 2 winnings per game: -0.39711 | |
Pick 3 winnings per game: -0.377799 | |
Pick 4 winnings per game: -0.387787 | |
Pick 5 winnings per game: -0.381384 | |
Pick 6 winnings per game: -0.430624 | |
Pick 7 winnings per game: -0.440436 | |
Pick 8 winnings per game: -0.407179 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
"L2 F2 R2 D' L2 F2 U' L2 D' L2 U B D B2 D R U' F' L B' F R", | |
"L2 D2 B2 U R2 F2 L2 D2 B2 D B2 F U' L U2 B2 D' L F2 L U2", | |
"D F2 U' F2 R2 B2 L2 U' B2 R2 U' L2 R D' B U' F U' B' L R U", | |
"D2 B2 U' B2 U' R2 D F2 U2 L2 F2 D' R' U' R2 D' B2 F' U L2 D2 F'", | |
"B2 U F2 D F2 D2 F2 D B2 L2 B2 R D2 F U' L' F' D' L F R F2", | |
"D' B2 R2 F2 U' R2 D' B2 U2 F2 D' U2 F' U B' R' F L' B2 R2 U' F", | |
"L2 B2 U F2 U' B2 F2 U2 B2 L2 U B2 F' U' L' B' F' L' U' B2 L2 U2", | |
"B2 D2 L2 F2 D2 L2 U B2 F2 U2 B' R' B' U F' R B' F2 U F2 D2 R", | |
"R2 D2 L2 U B2 D' B2 D' L2 U L2 U' B R' D' R' D' R2 D2 U2 B R'", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto') | |
describe('Predictable Randomness', () => { | |
describe('Math.random', () => { | |
const firstResult = 0.37454011430963874 | |
const secondResult = 0.7965429842006415 | |
beforeEach(() => Math.__clearChances__()) | |
it('should produce these two numbers first by default', () => { | |
expect(Math.random()).toEqual(firstResult) | |
expect(Math.random()).toEqual(secondResult) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A.Q@c6csm?-i+OG1+1OG1Z1HH2 | |
Two commands: | |
A .Q - Parse the input (.Q), assign 1st line (max dice number) to G and 2nd line (number of trials) to H | |
@c6csm?-i+OG1+1OG1Z1HH2 - The output | |
The output: | |
@c6csm?-i+OG1+1OG1Z1HH2 | |
@ c6csm?-i+OG1+1OG1Z1HH 2 - Take the square root of the middle chunk | |
c 6 csm?-i+OG1+1OG1Z1HH - Divide 6 by the 3rd chunk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numBars = 73 | |
bars = [0..numBars-1].map -> 0 | |
getDisplayBars = (audioData)-> | |
deltaT = audioData.length/numBars | |
bars[0] = audioData[0] | |
for barNum in [1..numBars-1] | |
timeIndex = barNum*deltaT | |
leftIndex = Math.floor timeIndex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
y = function(b){ | |
nums = [] | |
for(i=0; i<=Math.floor(Math.log(b)/Math.log(2)); i++) | |
nums.push(i); | |
d = nums.reduce(function(n, a){1<<n&b?3+a:4+a},0) | |
if(b == d) | |
return b | |
else | |
return y(b) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L?-b=dsm?.&.<1db3 4hlbydb@mXdH1mydSQ0 | |
L create lambda function named y with param b | |
? ternary if | |
- minus used for expressing "if d != b" | |
b lambda param | |
= assign | |
d d = | |
s sum | |
m map |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set l to Math.log because you use it twice | |
l = Math.log | |
# create a recursive function, r, to iterate on a chain until it reaches a fixed point | |
# n is the input for the current iteration | |
r = (n)-> | |
### | |
This next line is a mouthful. "l(n)/l 2" computes the log base 2 of n. This is the index of the highest set bit in n | |
The reduce function is basically a sum across the bits of the number. | |
It adds 3 to the sum if the bit is set ("one".length) and 4 if the bit is not set ("zero".length) | |
So, in a nutshell, z is set to the number of letters in the binary phrase for the number n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l=Math.log;r=((n)->z=[0..l(n)/l 2].reduce(((a,b)->`1<<b&n?3+a:4+a`),0);`z==n?n:r(z)`);c={};[1..1000000].map((n)->c[r n]?=0;c[r n]++);c |
NewerOlder