Twelve statements: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Minor tidy) |
(Added Uiua solution) |
||
Line 4,028: | Line 4,028: | ||
close 1 2 4 7 9 10 (wrong 10) |
close 1 2 4 7 9 10 (wrong 10) |
||
close 1 2 4 7 8 9 (wrong 8)</pre> |
close 1 2 4 7 8 9 (wrong 8)</pre> |
||
=={{header|Uiua}}== |
|||
{{works with|Uiua|0.10.0-dev.1}} |
|||
Defined the rules as functions to avoid the main loop devolving into line noise :-) |
|||
<syntaxhighlight lang="Uiua"> |
|||
Even ← =1◿2⇡⧻ # nb indexes are zero-based |
|||
SA ← =12⧻ # Total is twelve |
|||
SB ← =3⧻⊚↘6 # Three of last six are true |
|||
SC ← =2⧻⊚⊏⊚Even. # Exactly 2 even rules are true |
|||
SD ← ⟨1◌|/×⟩⊢.↙3↻4 # If 5 is true so are 6 and 7 |
|||
SE ← /׬⊏[1 2 3] # 2, 3, 4 are all false |
|||
SF ← =4⧻⊚⊏⊚¬Even. # Four odd rules are true |
|||
SG ← =1/+↙2↘1 # 2 xor 3 |
|||
SH ← ⟨1◌|/×⟩⊢.⇌↙3↻4 # If 7 is true so are 6 and 5 |
|||
SI ← =3⧻⊚↙6 # Three of first six are true |
|||
SJ ← /×⊏[10 11] # 11 and 12 are both true |
|||
SK ← =1/+⊏[6 7 8] # Exactly one of 7, 8, 9 is true |
|||
SL ← =4/+↘¯1 # Exactly four of above are true |
|||
≡( |
|||
# Test each rule against the data and concatenate |
|||
⊙⊂⟜SG⊙⊂⟜SH⊙⊂⟜SI⊙⊂⟜SJ⊙⊂⟜SK⟜SL |
|||
⊙⊂⟜SA⊙⊂⟜SB⊙⊂⟜SC⊙⊂⟜SD⊙⊂⟜SE⊙⊂⟜SF |
|||
⊟∩□:⊙(⊚⌵-). # Append hit-count |
|||
)⋯⇡4096 # Brute Force all combinations |
|||
# Partition by fit, keep only hits and near-misses |
|||
°⊟↙2⊕□≡(◇⧻⊢). |
|||
&p"\nNear Misses"&s+1◇⊚⊢↘1◇⊢&p"Hits" |
|||
⊏⍏≡⊢.°□ # Sort misses |
|||
≡(⊃(&p+1⊚°□⊢↘1)(&pf"\t"&pf+1◇⊢⊢&pf"Fails at ")) |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
Hits |
|||
[1 3 4 6 7 11] |
|||
Near Misses |
|||
Fails at 1 [5 8 11] |
|||
Fails at 1 [4 8 10 11 12] |
|||
Fails at 1 [5 8 10 11 12] |
|||
Fails at 6 [1 4 6 8 9] |
|||
Fails at 7 [1 3 4 8 9] |
|||
Fails at 8 [1 4] |
|||
Fails at 8 [1 5] |
|||
Fails at 8 [1 2 4 7 8 9] |
|||
Fails at 8 [1 5 6 9 11] |
|||
Fails at 9 [1 3 4 6 7 9] |
|||
Fails at 10 [1 2 4 7 9 10] |
|||
Fails at 11 [1 5 8] |
|||
Fails at 12 [1 5 8 11] |
|||
Fails at 12 [1 2 4 7 9 12] |
|||
Fails at 12 [1 4 8 10 11 12] |
|||
Fails at 12 [1 5 8 10 11 12]</pre> |
|||
=={{header|uBasic/4tH}}== |
=={{header|uBasic/4tH}}== |