Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 197 characters in body
Source Link
frasiyav
  • 799
  • 4
  • 6

BQN, 124(削除) 124 (削除ここまで) 114 bytes

4⊸⊑∨ ́{0=+ ́⥊x0=F⥊x?1;x≡◶S‿0x∧ ̋¬1;W←(∨ ́⊢≡⎉2<4⌽⥊)⎉2 3‿3↕⊢↑ ̋·≍⟜¬2+≢⋄x≡◶S‿0x∧ ́¬(F<≡ ̈(∨ ́·0⌾F0=⥊x(F ̈0=1↓ ̈W)⎉2G⎉2x∧⌾¬⎉2¬HF∘≥⚇1G{xS⍟≢(×ばつF×ばつ)∘⥊⎉2Gx ̈Wx}×ばつ⌾⥊0=x×ばつ⌾⥊0=x)∧⎉2⊢∧ ̈<)⎉2⊸ ̈⊸/(H←⍷∘⥊=⌜⊢)xGx}(3‿3↕⊢↑ ̋·≍⟜¬2+≢⍷∘⥊= ̈<)

Try it here. Try it here.

Fairly unsophisticated method: it flood fills the solved cells to find disconnected regions, then marks as solved cells where all cells of the same number border the edge or a single solved region, then repeats until all cells are solved, or the input no longer changes.

Can definitely be golfed a lot more. In particular, I think it could probably be rewritten to avoid having(削除) Can definitely be golfed a lot more. In particular, I think it could probably be rewritten to avoid having to use rank 2 (⎉2) everywhere. (削除ここまで)

Edit: rewrote to use rank 2each (⎉2 ̈) everywhereinstead of rank when possible and some other tweaks. Still a few parts I'm convinced can be improved, but I think ultimately trying a completely different approach would be better.

BQN, 124 bytes

4⊸⊑{0=+ ́⥊x?1;x≡◶S‿0x∧ ̋¬(∨ ́⊢≡⎉2((∨ ́·0⌾F0=⥊)⎉2G⎉2x∧⌾¬⎉2¬HF{xS⍟≢(×ばつF)∘⥊⎉2Gx}×ばつ⌾⥊0=x)∧⎉2⊢)⎉2⊸/(H←⍷∘⥊=⌜⊢)x}(3‿3↕⊢↑ ̋·≍⟜¬2+≢)

Try it here.

Fairly unsophisticated method: it flood fills the solved cells to find disconnected regions, then marks as solved cells where all cells of the same number border the edge or a single solved region, then repeats until all cells are solved, or the input no longer changes.

Can definitely be golfed a lot more. In particular, I think it could probably be rewritten to avoid having to use rank 2 (⎉2) everywhere.

BQN, (削除) 124 (削除ここまで) 114 bytes

∨ ́{0=F⥊x?1;W←(<4⌽⥊)⎉2 3‿3↕⊢↑ ̋·≍⟜¬2+≢⋄x≡◶S‿0x∧ ́¬(F<≡ ̈(x(F ̈0=1↓ ̈W)∘≥⚇1G{xS⍟≢(×ばつ) ̈Wx}×ばつ⌾⥊0=x)∧ ̈<) ̈⊸/Gx}(⍷∘⥊= ̈<)

Try it here.

Fairly unsophisticated method: it flood fills the solved cells to find disconnected regions, then marks as solved cells where all cells of the same number border the edge or a single solved region, then repeats until all cells are solved, or the input no longer changes.

(削除) Can definitely be golfed a lot more. In particular, I think it could probably be rewritten to avoid having to use rank 2 (⎉2) everywhere. (削除ここまで)

Edit: rewrote to use each ( ̈) instead of rank when possible and some other tweaks. Still a few parts I'm convinced can be improved, but I think ultimately trying a completely different approach would be better.

edited body
Source Link
frasiyav
  • 799
  • 4
  • 6

BQN, 124 bytes

4⊸⊑{0=+ ́⥊x?1;x≡◶S‿0x∧ ̋¬(∨ ́⊢≡⎉2((∨ ́·0⌾F0=⥊)⎉2G⎉2x∧⌾¬⎉2¬SF⎉2G⎉2x∧⌾¬⎉2¬HF{xS⍟≢(⌈ ×ばつF)×ばつ⌾⥊0=x)∧⎉2⊢)⎉2⊸/(S←⍷∘⥊=⌜⊢H←⍷∘⥊=⌜⊢)x}(3‿3↕⊢↑ ̋·≍⟜¬2+≢)

Try it here. Try it here.

Fairly unsophisticated method: it flood fills the solved cells to find disconnected regions, then marks as solved cells where all cells of the same number border the edge or a single solved region, then repeats until all cells are solved, or the input no longer changes.

Can definitely be golfed a lot more. In particular, I think it could probably be rewritten to avoid having to use rank 2 (⎉2) everywhere.

BQN, 124 bytes

4⊸⊑{0=+ ́⥊x?1;x≡◶S‿0x∧ ̋¬(∨ ́⊢≡⎉2((∨ ́·0⌾F0=⥊)⎉2G⎉2x∧⌾¬⎉2¬SF{xS⍟≢(⌈ ×ばつF)×ばつ⌾⥊0=x)∧⎉2⊢)⎉2⊸/(S←⍷∘⥊=⌜⊢)x}(3‿3↕⊢↑ ̋·≍⟜¬2+≢)

Try it here.

Fairly unsophisticated method: it flood fills the solved cells to find disconnected regions, then marks as solved cells where all cells of the same number border the edge or a single solved region, then repeats until all cells are solved, or the input no longer changes.

Can definitely be golfed a lot more. In particular, I think it could probably be rewritten to avoid having to use rank 2 (⎉2) everywhere.

BQN, 124 bytes

4⊸⊑{0=+ ́⥊x?1;x≡◶S‿0x∧ ̋¬(∨ ́⊢≡⎉2((∨ ́·0⌾F0=⥊)⎉2G⎉2x∧⌾¬⎉2¬HF{xS⍟≢(⌈ ×ばつF)×ばつ⌾⥊0=x)∧⎉2⊢)⎉2⊸/(H←⍷∘⥊=⌜⊢)x}(3‿3↕⊢↑ ̋·≍⟜¬2+≢)

Try it here.

Fairly unsophisticated method: it flood fills the solved cells to find disconnected regions, then marks as solved cells where all cells of the same number border the edge or a single solved region, then repeats until all cells are solved, or the input no longer changes.

Can definitely be golfed a lot more. In particular, I think it could probably be rewritten to avoid having to use rank 2 (⎉2) everywhere.

Source Link
frasiyav
  • 799
  • 4
  • 6

BQN, 124 bytes

4⊸⊑{0=+ ́⥊x?1;x≡◶S‿0x∧ ̋¬(∨ ́⊢≡⎉2((∨ ́·0⌾F0=⥊)⎉2G⎉2x∧⌾¬⎉2¬SF{xS⍟≢(⌈ ×ばつF)×ばつ⌾⥊0=x)∧⎉2⊢)⎉2⊸/(S←⍷∘⥊=⌜⊢)x}(3‿3↕⊢↑ ̋·≍⟜¬2+≢)

Try it here.

Fairly unsophisticated method: it flood fills the solved cells to find disconnected regions, then marks as solved cells where all cells of the same number border the edge or a single solved region, then repeats until all cells are solved, or the input no longer changes.

Can definitely be golfed a lot more. In particular, I think it could probably be rewritten to avoid having to use rank 2 (⎉2) everywhere.

AltStyle によって変換されたページ (->オリジナル) /