wrote code for part 1

This commit is contained in:
Tim Stallard 2017-12-04 00:41:06 +00:00
parent e7f7d65cae
commit 4f1bc11fa1
Signed by: Tim
GPG Key ID: AAE46381AF6A3FE8
2 changed files with 13 additions and 1 deletions

13
day03/part1.js Normal file
View File

@ -0,0 +1,13 @@
function getPos(num){
var bottomCorner = Math.ceil(Math.sqrt(num));
if(bottomCorner%2 == 0){
bottomCorner++;
}
var sidelength = bottomCorner - 1;
var timesRound = (Math.pow(bottomCorner, 2) - num) / (bottomCorner - 1);
var lastsection = timesRound % 1;
var centerdistance = (Math.abs(0.5 - lastsection)) * sidelength;
console.log((sidelength / 2) + centerdistance);
}
getPos(325489);

View File

@ -1 +0,0 @@
I just calculated it manually, I'll probably write some code for it sometime