wrote code for part 1
This commit is contained in:
parent
e7f7d65cae
commit
4f1bc11fa1
13
day03/part1.js
Normal file
13
day03/part1.js
Normal 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);
|
@ -1 +0,0 @@
|
||||
I just calculated it manually, I'll probably write some code for it sometime
|
Loading…
x
Reference in New Issue
Block a user