SQL works for me ;)
0 lines of code. No loops, no boolean flag, only SQL.
Get this table naming 'day3':
3.1 Solution
SELECT COUNT(*) FROM (SELECT id, REPEAT(line, 32) toboggan FROM day3 HAVING MID(toboggan, ( ( id * 3 ) - 2 ), 1) = '#') found_trees
3.2 Solution
SELECT ROUND(EXP(SUM(LN(x.a))),0) solution FROM ( SELECT COUNT(*) as a FROM (SELECT id, REPEAT(line, 32) toboggan FROM day3 HAVING MID(toboggan, id, 1) = '#') found_trees UNION ALL SELECT COUNT(*) FROM (SELECT id, REPEAT(line, 32) toboggan FROM day3 HAVING MID(toboggan, ( ( id * 3 ) - 2 ), 1) = '#') found_trees UNION ALL SELECT COUNT(*) FROM (SELECT id, REPEAT(line, 55) toboggan FROM day3 HAVING MID(toboggan, ( ( id * 5 ) - 4 ), 1) = '#') found_trees UNION ALL SELECT COUNT(*) FROM (SELECT id, REPEAT(line, 75) toboggan FROM day3 HAVING MID(toboggan, ( ( id * 7 ) - 6), 1) = '#') found_trees UNION ALL SELECT COUNT(*) FROM (SELECT id, REPEAT(line, 16) toboggan FROM day3 WHERE (id % 2) = 1 HAVING MID(toboggan, ((id + 1) / 2), 1) = '#') found_trees ) AS x
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
SQL works for me ;)
0 lines of code. No loops, no boolean flag, only SQL.
Get this table naming 'day3':
3.1 Solution
3.2 Solution