This repository was archived by the owner on Sep 22, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 33 files changed +689
-574
lines changed Expand file tree Collapse file tree 33 files changed +689
-574
lines changed Original file line number Diff line number Diff line change 1
- cookies.txt
1
+ cookies.txt
2
2
* .bak
Original file line number Diff line number Diff line change 1
- # !/usr/bin/env cbqn
2
-
3
- inp ← •FLines " 10.txt"
4
-
5
- strs ← (" " {
6
- 0 == 𝕨 ? 𝕨 ;
7
- ⊑ " {(<[" ∊ ˜ ⥊ 𝕩 ? 𝕨 ∾ 𝕩 ;
8
- (" {(<[" ∊ ¯1 ↑ 𝕨 )≡ " })>]" ∊⥊ 𝕩 ? ¯1 ↓ 𝕨 ;
9
- 𝕩
10
- }˜´ ⌽ )¨ inp
11
- •Show + ´ 3 ‿57 ‿1197 ‿25137 ⊏ ˜ " )]}>" ⊐ (1 =≠ ¨ )⊸ / strs
12
-
1
+ # !/usr/bin/env cbqn
2
+
3
+ inp ← •FLines " 10.txt"
4
+
5
+ strs ← (" " {
6
+ 0 == 𝕨 ? 𝕨 ;
7
+ ⊑ " {(<[" ∊ ˜ ⥊ 𝕩 ? 𝕨 ∾ 𝕩 ;
8
+ (" {(<[" ∊ ¯1 ↑ 𝕨 )≡ " })>]" ∊⥊ 𝕩 ? ¯1 ↓ 𝕨 ;
9
+ 𝕩
10
+ }˜´ ⌽ )¨ inp
11
+ •Show + ´ 3 ‿57 ‿1197 ‿25137 ⊏ ˜ " )]}>" ⊐ (1 =≠ ¨ )⊸ / strs
12
+
13
13
•Show {𝕩 ⊑ ˜ ⌊ 2 ÷ ˜ ≠ 𝕩 }∧ {{𝕨 + 5 × 𝕩 }´ 1 + " ([{<" ⊐ 𝕩 }¨ (1 ≠≠ ¨ )⊸ / strs
Original file line number Diff line number Diff line change 1
- [({(<(())[]>[[{[]{<()<>>
2
- [(()[<>])]({[<{<<[]>>(
3
- {([(<{}[<>[]}>{[]{[(<()>
4
- (((({<>}<{<{<>}{[]{[]{}
5
- [[<[([]))<([[{}[[()]]]
6
- [{[{({}]{}}([{[{{{}}([]
7
- {<[[]]>}<{[{[{[]{()[[[]
8
- [<(<(<(<{}))><([]([]()
9
- <{([([[(<>()){}]>(<<{{
1
+ [({(<(())[]>[[{[]{<()<>>
2
+ [(()[<>])]({[<{<<[]>>(
3
+ {([(<{}[<>[]}>{[]{[(<()>
4
+ (((({<>}<{<{<>}{[]{[]{}
5
+ [[<[([]))<([[{}[[()]]]
6
+ [{[{({}]{}}([{[{{{}}([]
7
+ {<[[]]>}<{[{[{[]{()[[[]
8
+ [<(<(<(<{}))><([]([]()
9
+ <{([([[(<>()){}]>(<<{{
10
10
<{([{{}}[<[[[<>{}]]]>[]]
Original file line number Diff line number Diff line change 1
- # !/usr/bin/env cbqn
2
-
3
- ⟨Pad ⟩ ← •Import " lib.bqn"
4
-
5
- inp ← > ' 0' - ˜ •FLines " 11.txt"
6
-
7
- Step ← {𝕊 ⍟ (∨ ´ ⥊ 𝕩 > 9 ) {x ←1 ‿1 ⊑ 𝕩 , (0 ≠ x )× (10 > x )× x ++ ´ 9 < (4 ⊸ ↑∾ ¯4 ⊸ ↑ )⥊ 𝕩 }⎉ 2 3 ‿3 ↕ 9 Pad 𝕩 }
8
- # Part 1:
9
- •Show + ´ 0 =∾⥊ ¨ (Step 1 ⊸ + )⍟ (1 +↕ 100 ) inp
10
-
11
- # Part 2:
1
+ # !/usr/bin/env cbqn
2
+
3
+ ⟨Pad ⟩ ← •Import " lib.bqn"
4
+
5
+ inp ← > ' 0' - ˜ •FLines " 11.txt"
6
+
7
+ Step ← {𝕊 ⍟ (∨ ´ ⥊ 𝕩 > 9 ) {x ←1 ‿1 ⊑ 𝕩 , (0 ≠ x )× (10 > x )× x ++ ´ 9 < (4 ⊸ ↑∾ ¯4 ⊸ ↑ )⥊ 𝕩 }⎉ 2 3 ‿3 ↕ 9 Pad 𝕩 }
8
+ # Part 1:
9
+ •Show + ´ 0 =∾⥊ ¨ (Step 1 ⊸ + )⍟ (1 +↕ 100 ) inp
10
+
11
+ # Part 2:
12
12
•Show 0 {(∧ ´ 0 =⥊ 𝕩 )◶ ⟨(𝕨 + 1 )⊸ 𝕊 Step , 𝕨 ⟩ 1 + 𝕩 } inp
Original file line number Diff line number Diff line change 1
- 5483143223
2
- 2745854711
3
- 5264556173
4
- 6141336146
5
- 6357385478
6
- 4167524645
7
- 2176841721
8
- 6882881134
9
- 4846848554
1
+ 5483143223
2
+ 2745854711
3
+ 5264556173
4
+ 6141336146
5
+ 6357385478
6
+ 4167524645
7
+ 2176841721
8
+ 6882881134
9
+ 4846848554
10
10
5283751526
Original file line number Diff line number Diff line change 1
- # !/usr/bin/env cbqn
2
-
3
- ⟨Split ⟩ ← •Import " lib.bqn"
4
-
5
- inp ← ' -' Split ¨ •FLines " 12.txt"
6
-
7
- # Part 1:
8
- nodes ← ⍷∾ inp
9
- conns ←{(nodes ⊐⊑ ¨ 𝕩 )⊔ ¯1 ⊑ ¨ 𝕩 }inp ∾⌽ ¨ inp
10
-
11
- •Show ⟨⟩{
12
- 𝕨 𝕊 " end" : 1 ;
13
- next ← (⊑ nodes ⊐⋈ 𝕩 )⊑ conns
14
- + ´ (𝕨 ∾ (' a' ≤⊑ 𝕩 )⥊⋈ 𝕩 )⊸ 𝕊 ¨ next (¬ ∘ ∊/⊣ )𝕨
15
- }" start"
16
-
17
- # Part 2:
18
- •Show ⟨" start" ⟩ {
19
- 𝕨 𝕊 " end" : 1 ;
20
- w Find x :
21
- next ← (⊑ nodes ⊐⋈ 𝕩 )⊑ conns
22
- sum ← + ´ 0 =∊ w (¬ ∘ ∊/⊣ )⟨" start" ⟩
23
- {
24
- (x ≡ " start" )∧ w ≢ ⟨" start" ⟩ ? 0 ;
25
- sum > 1 ? 0 ;
26
- 1 = sum ? + ´ {(w ∾ (' a' ≤⊑ x )⥊⋈ x ) Find 𝕩 }¨ next (¬ ∘ ∊/⊣ )w ;
27
- 0 = sum ? + ´ {(w ∾ (' a' ≤⊑ x )⥊⋈ x ) Find 𝕩 }¨ next
28
- }
1
+ # !/usr/bin/env cbqn
2
+
3
+ ⟨Split ⟩ ← •Import " lib.bqn"
4
+
5
+ inp ← ' -' Split ¨ •FLines " 12.txt"
6
+
7
+ # Part 1:
8
+ nodes ← ⍷∾ inp
9
+ conns ←{(nodes ⊐⊑ ¨ 𝕩 )⊔ ¯1 ⊑ ¨ 𝕩 }inp ∾⌽ ¨ inp
10
+
11
+ •Show ⟨⟩{
12
+ 𝕨 𝕊 " end" : 1 ;
13
+ next ← (⊑ nodes ⊐⋈ 𝕩 )⊑ conns
14
+ + ´ (𝕨 ∾ (' a' ≤⊑ 𝕩 )⥊⋈ 𝕩 )⊸ 𝕊 ¨ next (¬ ∘ ∊/⊣ )𝕨
15
+ }" start"
16
+
17
+ # Part 2:
18
+ •Show ⟨" start" ⟩ {
19
+ 𝕨 𝕊 " end" : 1 ;
20
+ w Find x :
21
+ next ← (⊑ nodes ⊐⋈ 𝕩 )⊑ conns
22
+ sum ← + ´ 0 =∊ w (¬ ∘ ∊/⊣ )⟨" start" ⟩
23
+ {
24
+ (x ≡ " start" )∧ w ≢ ⟨" start" ⟩ ? 0 ;
25
+ sum > 1 ? 0 ;
26
+ 1 = sum ? + ´ {(w ∾ (' a' ≤⊑ x )⥊⋈ x ) Find 𝕩 }¨ next (¬ ∘ ∊/⊣ )w ;
27
+ 0 = sum ? + ´ {(w ∾ (' a' ≤⊑ x )⥊⋈ x ) Find 𝕩 }¨ next
28
+ }
29
29
}" start"
Original file line number Diff line number Diff line change 1
- start-A
2
- start-b
3
- A-c
4
- A-b
5
- b-d
6
- A-end
1
+ start-A
2
+ start-b
3
+ A-c
4
+ A-b
5
+ b-d
6
+ A-end
7
7
b-end
Original file line number Diff line number Diff line change 1
- # !/usr/bin/env cbqn
2
-
3
- ⟨Split ⟩ ← •Import " lib.bqn"
4
-
5
- pts ‿folds ← " " < ⊸ Split •FLines " 13.txt"
6
- pts ↩ {⌽•BQN ¨ ' ,' Split 𝕩 }¨ pts
7
- folds ↩ {𝕊 ax ‿pos : ⟨(ax ≡ " y" )⊑⍉ ‿⊢ , •BQN pos ⟩}¨ {' =' Split ¯1 ⊑ ' ' Split 𝕩 }¨ folds
8
- grid ← ∊ ⟜ pts ˘ ↕ 1 +⌈ ´ pts
9
-
10
- # Part 1:
11
- Fold ← {Ax ‿pos 𝕊 𝕩 : Ax pos ↑ {m ←𝕨 ⌈ ○ ≠ 1 ↓ 𝕩 , 𝕨 ∨ ○ {𝕩 ↑ ˜ -+ ⟜ m ⊸ -≠ 𝕩 }⌽ 1 ↓ 𝕩 }´ (+ ` pos =↕≠Ax 𝕩 )⊔Ax 𝕩 }
12
- •Show + ´ ⥊ (⊑ folds ) Fold grid
13
-
14
- # Part 2:
1
+ # !/usr/bin/env cbqn
2
+
3
+ ⟨Split ⟩ ← •Import " lib.bqn"
4
+
5
+ pts ‿folds ← " " < ⊸ Split •FLines " 13.txt"
6
+ pts ↩ {⌽•BQN ¨ ' ,' Split 𝕩 }¨ pts
7
+ folds ↩ {𝕊 ax ‿pos : ⟨(ax ≡ " y" )⊑⍉ ‿⊢ , •BQN pos ⟩}¨ {' =' Split ¯1 ⊑ ' ' Split 𝕩 }¨ folds
8
+ grid ← ∊ ⟜ pts ˘ ↕ 1 +⌈ ´ pts
9
+
10
+ # Part 1:
11
+ Fold ← {Ax ‿pos 𝕊 𝕩 : Ax pos ↑ {m ←𝕨 ⌈ ○ ≠ 1 ↓ 𝕩 , 𝕨 ∨ ○ {𝕩 ↑ ˜ -+ ⟜ m ⊸ -≠ 𝕩 }⌽ 1 ↓ 𝕩 }´ (+ ` pos =↕≠Ax 𝕩 )⊔Ax 𝕩 }
12
+ •Show + ´ ⥊ (⊑ folds ) Fold grid
13
+
14
+ # Part 2:
15
15
•Show " 𝕊" ⊏ ˜ grid Fold ´ ⌽ folds
Original file line number Diff line number Diff line change 1
- 6,10
2
- 0,14
3
- 9,10
4
- 0,3
5
- 10,4
6
- 4,11
7
- 6,0
8
- 6,12
9
- 4,1
10
- 0,13
11
- 10,12
12
- 3,4
13
- 3,0
14
- 8,4
15
- 1,10
16
- 2,14
17
- 8,10
18
- 9,0
19
-
20
- fold along y=7
1
+ 6,10
2
+ 0,14
3
+ 9,10
4
+ 0,3
5
+ 10,4
6
+ 4,11
7
+ 6,0
8
+ 6,12
9
+ 4,1
10
+ 0,13
11
+ 10,12
12
+ 3,4
13
+ 3,0
14
+ 8,4
15
+ 1,10
16
+ 2,14
17
+ 8,10
18
+ 9,0
19
+
20
+ fold along y=7
21
21
fold along x=5
Original file line number Diff line number Diff line change 1
- # !/usr/bin/env cbqn
2
-
3
- ⟨Split ⟩ ← •Import " lib.bqn"
4
-
5
- ⟨pat ⟩‿strs ← " " < ⊸ Split •FLines " 14.txt"
6
- elems ‿trans ← < ˘ ⍉> {0 ‿2 ⊏ ' ' Split 𝕩 }¨ strs
7
-
8
- # Part 1:
9
- •Show (⌈ ´ -⌊ ´ )/ ⁼ ∘ ⊐∧ {∾ 𝕩 ∾ ¨ ⟨" " ⟩∾ ˜ trans ⊏ ˜ elems ⊐< ˘ 2 ↕ 𝕩 }⍟ 10 pat
10
-
11
- # Part 2(works for part 1 as well):
12
- npair ← trans {𝕨 𝕊 a ‿b : elems ⊐ ⟨a ∾ 𝕨 ,𝕨 ∾ b ⟩}¨ elems # indices of resultant pairs
13
- chars ← ⍷ elems ∾ ○ ∾ trans # all unique chars
14
- occs ← + ˝ pat = ⌜ chars # occurrence count of each char
15
- letinds ← chars ⊐∾ trans # indices of translated letters
16
-
17
- •Show (⌈ ´ -⌊ ´ )⊑ {
18
- 𝕊 n ‿x :
19
- new ← /⋈≠ x
20
- fil ← × ⊸ / x
21
- (2 / fil ){new 𝕨 ⊸ + ⌾ (𝕩 ⊸ ⊑ )↩}¨ ∾ npair / ˜ × x
22
- fil {n 𝕨 ⊸ + ⌾ (𝕩 ⊸ ⊑ )↩}¨ letinds / ˜ × x
23
- n ‿new
1
+ # !/usr/bin/env cbqn
2
+
3
+ ⟨Split ⟩ ← •Import " lib.bqn"
4
+
5
+ ⟨pat ⟩‿strs ← " " < ⊸ Split •FLines " 14.txt"
6
+ elems ‿trans ← < ˘ ⍉> {0 ‿2 ⊏ ' ' Split 𝕩 }¨ strs
7
+
8
+ # Part 1:
9
+ •Show (⌈ ´ -⌊ ´ )/ ⁼ ∘ ⊐∧ {∾ 𝕩 ∾ ¨ ⟨" " ⟩∾ ˜ trans ⊏ ˜ elems ⊐< ˘ 2 ↕ 𝕩 }⍟ 10 pat
10
+
11
+ # Part 2(works for part 1 as well):
12
+ npair ← trans {𝕨 𝕊 a ‿b : elems ⊐ ⟨a ∾ 𝕨 ,𝕨 ∾ b ⟩}¨ elems # indices of resultant pairs
13
+ chars ← ⍷ elems ∾ ○ ∾ trans # all unique chars
14
+ occs ← + ˝ pat = ⌜ chars # occurrence count of each char
15
+ letinds ← chars ⊐∾ trans # indices of translated letters
16
+
17
+ •Show (⌈ ´ -⌊ ´ )⊑ {
18
+ 𝕊 n ‿x :
19
+ new ← /⋈≠ x
20
+ fil ← × ⊸ / x
21
+ (2 / fil ){new 𝕨 ⊸ + ⌾ (𝕩 ⊸ ⊑ )↩}¨ ∾ npair / ˜ × x
22
+ fil {n 𝕨 ⊸ + ⌾ (𝕩 ⊸ ⊑ )↩}¨ letinds / ˜ × x
23
+ n ‿new
24
24
}⍟ 40 ⟨occs , + ´˘ elems ≡ ⌜ < ˘ 2 ↕ pat ⟩
You can’t perform that action at this time.
0 commit comments