Compare commits

..

No commits in common. "a234ea59b3d8960576a37f26c6ad8258374063f0" and "651418bea399c7f4bfddbcf55b1f52f9af56670a" have entirely different histories.

2 changed files with 1 additions and 68 deletions

View File

@ -1,7 +1,5 @@
package day10
import util.Ansi
import scala.collection.immutable.HashMap
import scala.collection.mutable.ArrayBuffer
import scala.io.{BufferedSource, Source}
@ -22,33 +20,10 @@ object Puzzle2 {
'S' -> 15
)
val TILE_CHARS: Map[Int, Char] = HashMap(
10 -> '│',
5 -> '─',
9 -> '└',
12 -> '┘',
6 -> '┐',
3 -> '┌',
0 -> ' ',
15 -> '█'
)
val TILE_CHARS_BOLD: Map[Int, Char] = HashMap(
10 -> '┃',
5 -> '━',
9 -> '┗',
12 -> '┛',
6 -> '┓',
3 -> '┏',
0 -> ' ',
15 -> '█'
)
var height: Int = 0
var width: Int = 0
var startX: Int = 0
var startY: Int = 0
var path: ArrayBuffer[(Int, Int)] = new ArrayBuffer()
def loadInput(path: String): Unit = {
val source: BufferedSource = Source.fromFile(path)
@ -72,30 +47,8 @@ object Puzzle2 {
source.close()
}
def display(): Unit = {
for (y: Int <- 0 until height) {
for (x: Int <- 0 until width) {
val tile: Byte = grid(y)(x)
val zone: Int = zones(y)(x)
if (zone == 1) {
print(Ansi.BG_RGB(163, 61, 61))
} else if (zone == 2) {
print(Ansi.BG_RGB(77, 163, 61))
}
if (path.contains((x, y))) {
print(Ansi.BOLD)
print(TILE_CHARS_BOLD(tile))
} else {
print(TILE_CHARS(tile))
}
print(Ansi.CLEAR)
}
println()
}
}
def calculateArea(): Int = {
path = new ArrayBuffer()
val path: ArrayBuffer[(Int, Int)] = new ArrayBuffer()
path.addOne((startX, startY))
val walker: Walker = new Walker(startX, startY)
@ -190,6 +143,5 @@ object Puzzle2 {
def main(args: Array[String]): Unit = {
val solution: Int = solve("./res/day10/input1.txt")
println(solution)
display()
}
}

View File

@ -1,19 +0,0 @@
package util
object Ansi {
val ESC: String = "\u001b["
val CLEAR: String = code("0")
val BOLD: String = code("1")
val FAINT: String = code("2")
val ITALIC: String = code("3")
val UNDERLINE: String = code("4")
val SLOW_BLINK: String = code("5")
val RAPID_BLINK: String = code("6")
val REVERSE: String = code("7")
val CONCEAL: String = code("8")
val STRIKETHROUGH: String = code("9")
def FG_RGB(r: Int, g: Int, b: Int): String = code(s"38;2;$r;$g;${b}")
def BG_RGB(r: Int, g: Int, b: Int): String = code(s"48;2;$r;$g;${b}")
private def code(str: String): String = ESC+str+"m"
}