From 4f1bc11fa12c3b8ecfe3d523e2d19b287b445eff Mon Sep 17 00:00:00 2001 From: TimStallard Date: Mon, 4 Dec 2017 00:41:06 +0000 Subject: [PATCH] wrote code for part 1 --- day03/part1.js | 13 +++++++++++++ day03/part1.txt | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 day03/part1.js delete mode 100644 day03/part1.txt diff --git a/day03/part1.js b/day03/part1.js new file mode 100644 index 0000000..a705fe0 --- /dev/null +++ b/day03/part1.js @@ -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); diff --git a/day03/part1.txt b/day03/part1.txt deleted file mode 100644 index 3fd6de9..0000000 --- a/day03/part1.txt +++ /dev/null @@ -1 +0,0 @@ -I just calculated it manually, I'll probably write some code for it sometime