Created
February 12, 2015 11:56
-
-
Save tzellman/1990dee3ead2b104ade1 to your computer and use it in GitHub Desktop.
This file contains 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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.winnings { | |
font: 100px/500px Menlo; | |
text-align: center; | |
width: 100%; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.1.0/lodash.min.js"></script> | |
<script> | |
var winning = {balls: [11, 13, 25, 39, 54], power: 19}; | |
var prizes = [ | |
[0, 1, 4], | |
[1, 1, 4], | |
[2, 1, 7], | |
[3, 0, 7], | |
[3, 1, 100], | |
[4, 0, 100], | |
[4, 1, 10000], | |
[5, 0, 1000000], | |
[5, 1, 500000000] | |
]; | |
d3.csv("numbers.csv", function(d){ | |
var total = 0; | |
d.forEach(function(nums){ | |
var balls = [nums.B1, nums.B2, nums.B3, nums.B4, nums.B5].map(function(b){return parseInt(b);}); | |
var power = parseInt(nums.PB); | |
var matchedBalls = _.intersection(balls, winning.balls).length; | |
var matchedPower = power === winning.power; | |
console.log(balls); | |
console.log(matchedBalls); | |
console.log(matchedPower); | |
prizes.forEach(function(p){ | |
if (p[0] === matchedBalls && !!p[1] === matchedPower){ | |
total += p[2]; | |
} | |
}); | |
}); | |
var div = d3.select("body").append("div") | |
.attr("class", "winnings").html("Winnings: $" + total); | |
console.log(total); | |
}); | |
</script> | |
</body> |
This file contains 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
B1 | B2 | B3 | B4 | B5 | PB | |
---|---|---|---|---|---|---|
2 | 32 | 39 | 45 | 57 | 10 | |
8 | 30 | 31 | 51 | 52 | 22 | |
7 | 12 | 13 | 22 | 53 | 26 | |
4 | 33 | 40 | 43 | 45 | 22 | |
4 | 21 | 30 | 38 | 40 | 21 | |
10 | 38 | 40 | 43 | 50 | 19 | |
4 | 26 | 31 | 36 | 55 | 26 | |
9 | 21 | 34 | 41 | 53 | 35 | |
9 | 24 | 25 | 31 | 37 | 5 | |
2 | 13 | 20 | 21 | 57 | 13 | |
2 | 31 | 54 | 58 | 59 | 32 | |
7 | 18 | 37 | 43 | 45 | 31 | |
32 | 46 | 51 | 52 | 59 | 35 | |
1 | 3 | 42 | 51 | 57 | 2 | |
9 | 11 | 13 | 28 | 53 | 22 | |
38 | 44 | 51 | 54 | 58 | 3 | |
23 | 29 | 31 | 41 | 50 | 35 | |
19 | 21 | 35 | 43 | 54 | 13 | |
7 | 26 | 46 | 48 | 52 | 7 | |
17 | 43 | 45 | 55 | 59 | 30 | |
1 | 4 | 37 | 46 | 57 | 28 | |
9 | 28 | 29 | 36 | 43 | 18 | |
6 | 27 | 52 | 54 | 57 | 30 | |
4 | 23 | 25 | 42 | 52 | 34 | |
9 | 33 | 37 | 41 | 59 | 12 | |
28 | 36 | 39 | 46 | 51 | 3 | |
3 | 19 | 44 | 47 | 59 | 7 | |
26 | 33 | 34 | 54 | 59 | 21 | |
1 | 11 | 15 | 30 | 56 | 24 | |
17 | 28 | 53 | 56 | 59 | 10 | |
7 | 10 | 23 | 24 | 39 | 31 | |
3 | 12 | 15 | 16 | 39 | 14 | |
18 | 44 | 55 | 57 | 58 | 13 | |
10 | 12 | 31 | 33 | 35 | 17 | |
7 | 29 | 46 | 49 | 59 | 23 | |
27 | 44 | 46 | 47 | 52 | 32 | |
8 | 9 | 16 | 35 | 59 | 35 | |
3 | 22 | 23 | 28 | 42 | 19 | |
17 | 21 | 33 | 43 | 49 | 29 | |
5 | 17 | 35 | 40 | 46 | 29 | |
1 | 7 | 15 | 30 | 54 | 6 | |
32 | 41 | 45 | 49 | 57 | 33 | |
3 | 9 | 20 | 22 | 38 | 9 | |
11 | 25 | 36 | 38 | 43 | 23 | |
13 | 38 | 40 | 54 | 55 | 17 | |
6 | 33 | 38 | 46 | 59 | 24 | |
16 | 19 | 25 | 28 | 41 | 1 | |
10 | 25 | 36 | 38 | 40 | 34 | |
17 | 18 | 21 | 39 | 52 | 20 | |
15 | 43 | 46 | 47 | 48 | 34 | |
2 | 10 | 18 | 24 | 27 | 29 | |
3 | 16 | 28 | 36 | 45 | 31 | |
7 | 21 | 29 | 49 | 50 | 10 | |
11 | 14 | 22 | 51 | 52 | 24 | |
13 | 32 | 40 | 54 | 55 | 27 | |
4 | 17 | 23 | 31 | 46 | 9 | |
10 | 32 | 41 | 43 | 44 | 29 | |
5 | 11 | 22 | 33 | 37 | 4 | |
9 | 17 | 28 | 29 | 31 | 2 | |
8 | 9 | 11 | 26 | 49 | 13 | |
30 | 47 | 49 | 51 | 56 | 23 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment