Skip to content

Instantly share code, notes, and snippets.

View BunnyCinnamon's full-sized avatar
😭
😭

Cinnamon BunnyCinnamon

😭
😭
  • Behind you
View GitHub Profile
import org.springframework.batch.core.*
@Grab('org.springframework.batch:spring-batch-core:3.0.6.RELEASE')
import org.springframework.batch.core.configuration.annotation.*
import org.springframework.batch.core.job.builder.FlowBuilder
import org.springframework.batch.core.job.flow.Flow
import org.springframework.batch.core.launch.JobLauncher
import org.springframework.batch.core.listener.ExecutionContextPromotionListener
import org.springframework.batch.core.partition.support.Partitioner
import org.springframework.batch.core.scope.context.ChunkContext
import org.springframework.batch.core.scope.context.StepSynchronizationManager
# Configuration file
general {
S:config <
#########Comments are prefixed with '#'
#########
###Amounts can vary, there are percentages (%) and seconds (s)
###Anything outside is considered a default
###You can put spaces to make it look better
min_level: 0
@BunnyCinnamon
BunnyCinnamon / Day9.scala
Last active December 10, 2020 03:50
Find numbers
package advent
object Day9 {
def main(args: Array[String]): Unit = {
import File._
def findPair(array: List[Long], num: Long) = {
@scala.annotation.tailrec
def recursiveFindPair(l: Int, r: Int): Option[(Long, Long)] = {
@BunnyCinnamon
BunnyCinnamon / Day8.scala
Created December 10, 2020 00:38
Execute instructions
package advent
object Day8 {
def main(args: Array[String]): Unit = {
import File._
def execute1(operations: Seq[(String, Int)]): Int = {
@scala.annotation.tailrec
def recursive(pointer: Int, result: Int)(visits: Array[Int]): Int = {
@BunnyCinnamon
BunnyCinnamon / Day7.scala
Created December 9, 2020 19:43
Bags > bags > bags > bags > bags > bags > bags > bags
package advent
object Day7 {
def main(args: Array[String]): Unit = {
import File._
def find(map: Map[String, Seq[String]], current: String)(lookup: String): Boolean = {
map(current).distinct match {
case seq@_ => if(seq.contains(lookup)) true else seq.exists(find(map, _) {lookup})
@BunnyCinnamon
BunnyCinnamon / Day6.scala
Last active December 10, 2020 00:15
Find duplicate answers and count them
package advent
object Day6 {
def main(args: Array[String]): Unit = {
import File._
def concat(last: String, next: String) = {
if (next.isEmpty) last + " "
else last + next
@BunnyCinnamon
BunnyCinnamon / Day5.scala
Created December 5, 2020 16:16
Find seat codes on plane and then missing seats
package advent
object Day5 {
def main(args: Array[String]): Unit = {
import File._
def floor(a: Int, b: Int) = ((b - a) / 2).floor.toInt
def ceil(a: Int, b: Int) = ((b - a) / 2).ceil.toInt
@BunnyCinnamon
BunnyCinnamon / Day4.scala
Last active December 4, 2020 07:57
Count valid passports in a semi-formatted list
package advent
object Day4 {
def main(args: Array[String]): Unit = {
import File._
def validate(data: String): Boolean = {
data.split(':') match {
case Array(a, b) => a match {
@BunnyCinnamon
BunnyCinnamon / Day3.scala
Last active December 4, 2020 02:00
Find prodict of trees in a group of slopes
package advent
object Day3 {
def main(args: Array[String]): Unit = {
import File._
def hasTree(line: String, pos: Int): Boolean = line(pos % line.length) == '#'
println({
@BunnyCinnamon
BunnyCinnamon / Day2.scala
Last active December 4, 2020 02:07
Password pattern matching
package advent
import scala.util.matching.Regex
object Day2 {
val regex: Regex = "(\\d+-\\d+) ([a-z]): ([a-z]*)".r
def main(args: Array[String]): Unit = {
import File._