28 lines
1.2 KiB
Text
28 lines
1.2 KiB
Text
Even ← =1◿2⇡⧻ # nb indexes are zero-based
|
||
SA ← =12⧻ # Total is always twelve (don't test)
|
||
SB ← =3⧻⊚↘6 # Three of last six are true
|
||
SC ← =2⧻⊚⊏⊚Even. # Exactly two 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
|
||
|
||
⋯+1×2⇡2048 # Brute force sensible combinations
|
||
≡(
|
||
# Test each rule against the data and concatenate
|
||
:[⊃⊃⊃⊃⊃⊃⊃⊃⊃⊃⊃SA SB SC SD SE SF SG SH SI SJ SK SL].
|
||
⊟∩□:⊙(⊚⌵-). # Append hit-count
|
||
)
|
||
|
||
# Partition by fit, keep only hits and near-misses
|
||
°⊟↙2⊕□≡(◇⧻⊢).
|
||
|
||
# Print results
|
||
&p"\nNear Misses"&s+1◇⊚⊢↘1◇⊢&p"Hits"
|
||
⊏⍏≡⊢.°□ # Sort misses
|
||
≡(⊃(&p+1⊚°□⊢↘1)(&pf"\t"&pf+1◇⊢⊢&pf"Fails at "))
|