September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
26
Task/Twelve-statements/Sidef/twelve-statements.sidef
Normal file
26
Task/Twelve-statements/Sidef/twelve-statements.sidef
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
var conditions = [
|
||||
{ false },
|
||||
{|a| a.len == 13 },
|
||||
{|a| Math.sum(a[7..12]) == 3 },
|
||||
{|a| Math.sum(a[2..12 `by` 2]) == 2 },
|
||||
{|a| a[5] ? (a[6] && a[7]) : true },
|
||||
{|a| !a[2] && !a[3] && !a[4] },
|
||||
{|a| Math.sum(a[1..11 `by` 2]) == 4 },
|
||||
{|a| a[2] == true^a[3] },
|
||||
{|a| a[7] ? (a[5] && a[6]) : true },
|
||||
{|a| Math.sum(a[1..6]) == 3 },
|
||||
{|a| Math.sum(a[11,12]) == 2 },
|
||||
{|a| Math.sum(a[7..9]) == 1 },
|
||||
{|a| Math.sum(a[1..11]) == 4 },
|
||||
]
|
||||
|
||||
func miss(args) {
|
||||
1..12 -> grep {|i| conditions[i](args) != args[i] }
|
||||
}
|
||||
|
||||
for k in (^(1<<12)) {
|
||||
var t = ("0%012b" % k -> chars.map {|bit| bit == '1' ? true : false })
|
||||
var no = miss(t)
|
||||
no.len == 0 && say "Solution: true statements are #{1..12->grep{t[_]}.join(' ')}"
|
||||
no.len == 1 && say "1 miss (#{no[0]}): true statements are #{1..12->grep{t[_]}.join(' ')}"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue