This is a function that is called to remove all preceding elements in an array in OCaml
To run call nub2 [1;4;2;3;1;2;1;1;4;2];; and you should receieve int list = [1; 4; 2; 3] - all repeated elements are removed
| class Item extends React.Component { | |
| constructor(props){ | |
| super(props); | |
| this.state = { | |
| name: props.name, | |
| count: props.count | |
| } | |
| } | 
| const day03_a = input => { | |
| // NOTE: Doesn't work for actual square numbers, too lazy to fix, deal with it | |
| // n = the square root of the nearest square number below it | |
| // m = the square root of the nearest square number above it | |
| const n = roundDownToNearestOddNumber(Math.sqrt(input)) | |
| const n2 = n * n | |
| // amount of steps to reach the nth corner [not the mth] | |
| const steps_for_n = (n + 1) / 2 | 
| [1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1] | |
| [1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1] | |
| [1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, - | 
| Both players pick a number, if it's the same no one wins, if it's an even number P1 wins and if it's odd P2 wins. | |
| Given a set of numbers {1,2,3} P2 is always more likely to win the more games they play | |
| All of the events are just as likely to happen (if they choose randomly) | |
| {1,1} = Same number = No one wins | |
| {1,2} = 3 = Odd = P2 | |
| {1,3} = 4 = Even = P1 | |
| {2,1} = 3 = = P2 | 
A little function that I thought would be useful to create a tuple of rgb percentages from a hex string.
The original function was contained within a file of many special functions (which is why you must specify hex2rgb as the first param, this will be changed in a future release)
Call the function with a parameter of hex2rgb and a second of a hex string 0xf93819.
It will display variable outputs that may be useful:
e2 will output 226e2 will output .88{.88, .32, .12}