Skip to content

Commit

Permalink
Day 15, starting progress
Browse files Browse the repository at this point in the history
  • Loading branch information
romellem committed Jul 13, 2019
1 parent e6e6b40 commit 548c1e8
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
37 changes: 37 additions & 0 deletions 2018/15/combat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const distance = require('manhattan');

class Unit {
constructor(type, x, y, attack = 3, hp = 200) {}
}

class MapPoint {
constructor(type, x, y) {
this.x = x;
this.y = y;

this.type = type;
this.isWall = this.type === '#';
}
}

class Combat {
constructor(raw_map) {
let map_and_units = this.parseMap(raw_map);
this.map = map_and_units.map;
this.units = map_and_units.units;
}

parseMap(raw_map) {
let initial_map = raw_map.split('\n').map(row => row.split(''));
let map = initial_map.map((row, y) =>
row.map((cell, x) => new MapPoint(cell === '#' ? '#' : '.', x, y))
);

return {
map,
units,
};
}
}

module.exports = Combat;
Empty file added 2018/15/input.js
Empty file.
32 changes: 32 additions & 0 deletions 2018/15/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
################################
#########################.G.####
#########################....###
##################.G.........###
##################.##.......####
#################...#.........##
################..............##
######..########...G...#.#....##
#####....######.G.GG..G..##.####
#######.#####G............#.####
#####.........G..G......#...####
#####..G......G..........G....##
######GG......#####........E.###
#######......#######..........##
######...G.G#########........###
######......#########.....E..###
#####.......#########........###
#####....G..#########........###
######.##.#.#########......#####
#######......#######.......#####
#######.......#####....E...#####
##.G..#.##............##.....###
#.....#........###..#.#.....####
#.........E.E...#####.#.#....###
######......#.....###...#.#.E###
#####........##...###..####..###
####...G#.##....E####E.####...##
####.#########....###E.####....#
###...#######.....###E.####....#
####..#######.##.##########...##
####..######################.###
################################
Empty file added 2018/15/part-one.js
Empty file.
Empty file added 2018/15/part-two.js
Empty file.

0 comments on commit 548c1e8

Please sign in to comment.