From ac1f723d39b6d25903237af86a7319209373731b Mon Sep 17 00:00:00 2001 From: mathiasmagnusson Date: Fri, 9 Dec 2022 18:01:29 +0100 Subject: Code jam --- code-jam22/round1/3d-printing.jl | 26 ++++++++++++++++++++++++++ code-jam22/round1/d1000000.jl | 11 +++++++++++ code-jam22/round1/punched-cards.jl | 12 ++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 code-jam22/round1/3d-printing.jl create mode 100644 code-jam22/round1/d1000000.jl create mode 100644 code-jam22/round1/punched-cards.jl (limited to 'code-jam22/round1') diff --git a/code-jam22/round1/3d-printing.jl b/code-jam22/round1/3d-printing.jl new file mode 100644 index 0000000..c003a4b --- /dev/null +++ b/code-jam22/round1/3d-printing.jl @@ -0,0 +1,26 @@ +cases = parse(Int, readline()) + +for case = 1:cases + colors = reduce(hcat, map(1:3) do () + parse.(Int, split(readline())) + end) + print("Case #", case, ": ") + m = map(1:4) do c minimum(colors[c, :]) end + over = sum(m) - 1_000_000 + if over < 0 + println("IMPOSSIBLE") + else + i = 1 + while over > 0 + if m[i] ≥ over + m[i] -= over + break + else + over -= m[i] + m[i] = 0 + i += 1 + end + end + println(join(m, ' ')) + end +end diff --git a/code-jam22/round1/d1000000.jl b/code-jam22/round1/d1000000.jl new file mode 100644 index 0000000..c1db6e1 --- /dev/null +++ b/code-jam22/round1/d1000000.jl @@ -0,0 +1,11 @@ +t = parse(Int, readline()) + +for case = 1:t + readline() + ds = readline() |> split .|> (x -> parse(Int, x)) |> sort + at = 0 + for d = ds + at += d > at + end + println("Case #", case, ": ", at) +end diff --git a/code-jam22/round1/punched-cards.jl b/code-jam22/round1/punched-cards.jl new file mode 100644 index 0000000..16bd228 --- /dev/null +++ b/code-jam22/round1/punched-cards.jl @@ -0,0 +1,12 @@ +t = parse(Int, readline()) +for i = 1:t + r, c = parse.(Int, split(readline())) + println("Case #", i, ":") + println("..+" * "-+" ^ (c - 1)) + println("..|" * ".|" ^ (c - 1)) + for y = 1:(r-1) + println("+" * "-+" ^ c) + println("|" * ".|" ^ c) + end + println("+" * "-+" ^ c) +end -- cgit v1.2.3