Skip to content

Instantly share code, notes, and snippets.

View trys's full-sized avatar
🤓
🚀

Trys Mudford trys

🤓
🚀
View GitHub Profile
@trys
trys / heights.js
Created April 10, 2015 17:12
Match column heights
MatchColumnHeights: function( group, width ) {
var tallest = 0,
gCount,
subGroup,
splitGroup,
i;
splitGroup = [];
@trys
trys / fourteen.js
Created September 22, 2015 19:44
Problem Fourteen
var termCount = 1,
termTotal = 1,
termIndex = 0;
current = 13,
discountable = {};
for ( var i = 1; i < 1000000; i++ ) {
current = i;
if ( ! ( current in discountable ) ) {
while ( current != 1 ) {
@trys
trys / thirteen.js
Created September 22, 2015 20:16
Problem Thirteen
var numberArray = [
37107287533902102798797998220837590246510135740250,
46376937677490009712648124896970078050417018260538,
74324986199524741059474233309513058123726617309629,
91942213363574161572522430563301811072406154908250,
23067588207539346171171980310421047513778063246676,
89261670696623633820136378418383684178734361726757,
28112879812849979408065481931592621691275889832738,
44274228917432520321923589422876796487670272189318,
47451445736001306439091167216856844588711603153276,
@trys
trys / fifteen.js
Created October 27, 2015 20:39
Problem Fifteen
var result = 0,
i,
j;
for ( i = 1; i <= 20; i++ ) {
result = 1;
for ( j = (2*i) - i + 1; j <= (2*i); j++) {
result *= j;
}
@trys
trys / sixteen.js
Created October 27, 2015 20:55
Problem Sixteen
var result = 0,
count = 0;
result = bigInt(2).pow( 1000 ).toString();
for (var i = result.length - 1; i >= 0; i--) {
count += parseInt( result[ i ] );
}
document.write( count );
@trys
trys / seventeen.js
Created October 27, 2015 23:19
Problem Seventeen
function nameNumber( count ) {
var ones = [ '', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen' ],
tens = [ 'zero', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety' ];
// Thousands
if ( count === 1000 ) {
return 'one thousand';
}
@trys
trys / nineteen.js
Created October 27, 2015 23:20
Problem Nineteen
var date,
counter = 0;
for (var i = 1901; i <= 2000; i++) {
for (var j = 1; j <= 12; j++) {
date = new Date( i + '-' + pad( j ) + '-01' );
if ( date.getDay() === 0 ) {
counter++;
}
}
@trys
trys / twenty.js
Created October 28, 2015 19:10
Problem Twenty
function factorial( n ) {
var product = bigInt(1);
for (var i = n; i > 0; i--) {
product = product.multiply( i );
}
return product.toString();
}
var number = factorial( 100 ),
result = 0;
@trys
trys / twenty-one.js
Created October 28, 2015 20:09
Problem Twenty One
var results = [],
a,
b;
function divisors( a ) {
var divisor = [];
for (var i = 1; i <= a / 2; i++) {
if ( a % i === 0 ) {
divisor.push( i );
}
@trys
trys / twenty-two.js
Created October 28, 2015 21:28
Problem Twenty Two
var names = names.sort(),
alpha = {
A: 1,
B: 2,
C: 3,
D: 4,
E: 5,
F: 6,
G: 7,
H: 8,