finally add real logical operators
This commit is contained in:
@@ -2,13 +2,13 @@ func check[report: array] : bool
|
||||
let increasing: bool = array.nth(report, 0) < array.nth(report, 1)
|
||||
|
||||
for i in 0..array.size(report)-1
|
||||
if array.nth(report, i) > array.nth(report, i + 1) & increasing
|
||||
if array.nth(report, i) > array.nth(report, i + 1) && increasing
|
||||
return false
|
||||
if array.nth(report, i) < array.nth(report, i + 1) & !increasing
|
||||
if array.nth(report, i) < array.nth(report, i + 1) && !increasing
|
||||
return false
|
||||
|
||||
let diff: i64 = math.abs(array.nth(report, i) - array.nth(report, i + 1))
|
||||
if diff < 1 | diff > 3
|
||||
if diff < 1 || diff > 3
|
||||
return false
|
||||
|
||||
return true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
func check[lines: array, x: i64, y: i64, dx: i64, dy: i64] : bool
|
||||
if x + dx * 3 < 0 | x + dx * 3 >= array.size(lines) | y + dy * 3 < 0 | y + dy * 3 >= str.len(array.nth(lines, 0))
|
||||
if x + dx * 3 < 0 || x + dx * 3 >= array.size(lines) || y + dy * 3 < 0 || y + dy * 3 >= str.len(array.nth(lines, 0))
|
||||
return false
|
||||
|
||||
if array.nth(lines, x)[y] != 'X'
|
||||
@@ -50,7 +50,7 @@ func part2[lines: array] : void
|
||||
str.set(s, 3, array.nth(lines, x - 1)[y + 1])
|
||||
str.set(s, 4, 0)
|
||||
|
||||
if str.equal(s, "MSSM") | str.equal(s, "SMMS") | str.equal(s, "MMSS") | str.equal(s, "SSMM")
|
||||
if str.equal(s, "MSSM") || str.equal(s, "SMMS") || str.equal(s, "MMSS") || str.equal(s, "SSMM")
|
||||
out = out + 1
|
||||
|
||||
io.println_i64(out)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
func rule_exists[rules_left: array, rules_right: array, a: i64, b: i64] : bool
|
||||
for k in 0..array.size(rules_left)
|
||||
if array.nth(rules_left, k) == a & array.nth(rules_right, k) == b
|
||||
if array.nth(rules_left, k) == a && array.nth(rules_right, k) == b
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@ func main[] : i64
|
||||
let sum = 0
|
||||
|
||||
for i in 0..1000
|
||||
if i % 5 == 0 | i % 3 == 0
|
||||
if i % 5 == 0 || i % 3 == 0
|
||||
sum = sum + i
|
||||
io.println_i64(sum)
|
||||
@@ -1,10 +1,10 @@
|
||||
func days[y: i64, m: i64] : i64
|
||||
if m == 2
|
||||
if (((y % 4 == 0) & (y % 100 != 0)) | (y % 400 == 0))
|
||||
if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0))
|
||||
return 29
|
||||
else
|
||||
return 28
|
||||
else if (m == 4) | (m == 6) | (m == 9) | (m == 11)
|
||||
else if (m == 4) || (m == 6) || (m == 9) || (m == 11)
|
||||
return 30
|
||||
else
|
||||
return 31
|
||||
|
||||
@@ -15,7 +15,7 @@ func main[] : i64
|
||||
|
||||
for i in 2..10000
|
||||
let d: i64 = divisors_sum(i)
|
||||
if i < d & i == divisors_sum(d)
|
||||
if i < d && i == divisors_sum(d)
|
||||
sum = sum + i + d
|
||||
|
||||
io.println_i64(sum)
|
||||
Reference in New Issue
Block a user