Skip to content

Instantly share code, notes, and snippets.

@segomin
segomin / algol.5.4.txt
Last active May 31, 2024 13:00
algol.5.4
5.4 (-true == false 증명)
-p == p == false
when) p := false
-false == false == false
-false == true
then) p := true
@segomin
segomin / algo4.1.md
Last active April 19, 2024 13:27
algo4.1

4.1 12/31 일을 말하면 승리 (1/1 부터 시작)

  • A) 다음달의 1일을 말하거나, 그 달에 있는 아무 날(상대방 날짜 이후)

    • 1월을 마지막을 먼저 말하면 됨 : 12/1 일을 먼저 말하는 사람이 패배, 11월의 마지막을 말하면 승리
    • 10, 9, 8... 1 월의 마지막 날짜를 말하면 승리
  • B) 다음달 1일을 말하거나 바로 다음날을 말함

    • 12/1 을 말하면 12/31 을 부르는 순서가 됨, 따라서 11월의 어느날을 말하면 패배,
    • 10/31 일을 말하면 승리 하므로 역시 10/1일을 말하면 승리
  • 9/1 일을 먼저 말하면 패배

@segomin
segomin / algo3.15.md
Last active April 19, 2024 12:08
algo3.15
  • 최소 필요시간 8
L - R time
11444 -
11 1
444 11
1 1 1
1444 1
444 4
@segomin
segomin / algo3.13
Last active April 19, 2024 11:27
algo3.13
if t.3 + t.1 ≤ 2 × t.2
2 x t.1 + t.2 + t.3 + t.4
else
t.1 + 3 x t.2 + t4
fi
when (5m + 1m > 2 x 2m)
then (1m + 3 x 2m + 10m) => 17m
when (t.3 + t.1 < 2 × t.2) t.1 이 매번 건너는게 빠름
@segomin
segomin / algo3.5.md
Created April 12, 2024 12:34
algo3.5
-1 0 1 2 3 4 5
1
1 1 1
1 2 1 1
2 1
2 1 1 1
1 1 1
1 1 1 1 1
1 1 1
@segomin
segomin / algo3.6.md
Last active April 12, 2024 12:29
algo3.6
-1 0 1 2 3 4
. 1 . . . .
1 2 1 . . .
1 3 2 1 . .
1 3 3 2 1 .
. 2 2 2 1 .
. 1 1 1 1 .
. 1 2 2 2 .
. 1 2 3 3 1
@segomin
segomin / CutChocolate.scala
Created March 8, 2024 12:20
cut chocolate
import scala.annotation.tailrec
case class Chocolate(height: Int, width: Int) {
def cut: Option[(Chocolate, Chocolate)] = {
if (height == 1 && width == 1) return None
val (hs, ws) = (height, width) match {
case (1, w) => ((1, 1), split(width))
case (h, 1) => (split(height), (1, 1))
@segomin
segomin / aoc2023_day09.scala
Last active February 16, 2024 12:52
aoc2023_day09.scala
import utils.loadInput
import scala.annotation.tailrec
@main def main: Unit =
val testInput = """0 3 6 9 12 15
|1 3 6 10 15 21
|10 13 16 21 30 45
|""".stripMargin
@segomin
segomin / aoc2023_day08.scala
Last active January 30, 2024 11:41
aoc2023_day08.scala
import inputs.Input.loadFileSync
import locations.Directory.currentDir
import scala.annotation.tailrec
def loadInput(filename: String) = loadFileSync(s"$currentDir/input/$filename")
@main def main: Unit =
val testInput = """RL
@segomin
segomin / aoc2023_day07.scala
Last active January 21, 2024 07:19
aoc2023_day07.scala
import utils.loadInput
import scala.collection.immutable.List
@main def main: Unit =
// card and money pairs
val testInput = """32T3K 765
|T55J5 684
|KK677 28
|KTJJT 220