Paste: AOC Day 3

Author: erg
Mode: factor
Date: Sat, 4 Dec 2021 04:24:11
Plain Text |
CONSTANT: nums "001001100101\n010100011100\n100000110001\n001111110101\n100010110101\n111010100100\n011011000110\n100000011101\n011001100111\n000001011110\n000010100011\n110100111110\n001101100101\n011011011101\n010000011010\n011100100100\n001111000011\n100111000111\n100111100011\n101100011011\n001110101101\n110010101000\n111110110111\n111100100010\n001001000000\n001111101011\n101100110011\n011010001111\n100010100001\n110011001010\n101000001100\n111010101100\n101010101100\n110011101000\n001110010110\n010101001001\n000010101100\n010101101010\n111001101100\n010000000000\n011011111000\n001110110011\n101000001011\n110101100101\n111001010111\n110001111111\n010010100110\n011010011001\n011101100000\n100110010101\n111000101101\n110011110000\n011001011000\n001101000010\n001110011111\n100010101100\n010011100101\n000011110000\n101100001111\n010001011000\n001101011101\n011110001110\n111110101101\n010000000011\n111000000011\n000100010100\n111110011001\n111001010011\n011000100010\n100001110000\n111111000100\n010100101110\n010011100110\n101100110111\n101001101001\n000001110111\n101100000001\n011010111011\n110011011111\n001001011001\n010110101100\n001100101100\n101001011101\n100101000010\n010101000010\n111101011110\n000000100010\n111010010010\n100001111011\n110000010011\n000101111001\n111101100111\n110101011100\n000111110101\n011110111001\n010000101011\n001001011000\n010110011100\n111111111000\n110100000101\n110101010011\n010011110010\n100110111100\n111000001101\n110001001001\n111101111100\n111111101001\n100101001010\n010101010100\n010010001111\n000010110000\n011001110110\n111101111011\n011001011100\n110101010101\n110111011111\n110101111000\n110010100110\n110000000010\n011001100001\n011000110010\n010110100000\n011110000001\n100101011010\n100111111011\n001110000011\n100110011011\n000100011101\n110000110110\n000001000010\n011111111010\n001010100100\n011000100100\n001100001111\n010111100111\n010001101101\n011001010000\n001010101000\n001001100011\n000011001010\n010010010100\n100001011000\n000011011011\n111011110111\n100010010000\n111001110000\n011100010100\n000101101011\n010000000010\n001101110100\n111010111111\n011000011110\n111110000110\n011011011011\n010001000100\n110111010010\n001110010100\n001001011010\n010111100011\n110110110101\n110101000101\n001011100011\n001111010110\n110111011000\n110001011110\n011101000001\n101111100000\n110001101110\n010101101100\n010010100010\n000111101010\n010000001010\n011001000010\n100000010110\n111101010010\n111011001011\n000010100010\n011111111001\n111001001011\n101001111010\n110100000001\n010010101111\n110011111001\n110111100110\n100111001111\n100101101001\n011111100100\n011111011011\n111100101101\n110010000111\n110110010000\n011101111011\n001101101000\n001001100110\n110001101000\n111100101110\n000101110111\n011110101111\n000100010010\n011010000011\n010010100001\n111001111110\n001111101010\n101110100011\n100111111001\n110110011010\n000100001000\n111011010010\n011001101110\n001011011010\n101110111100\n110011010110\n001010100011\n111010111110\n011100010011\n100011010100\n110000111010\n110001010001\n001111101001\n010011100111\n101010111010\n110101001101\n000100111000\n100101001001\n101110111011\n001110011000\n011000010010\n001000010001\n000111011101\n100000111100\n001110000100\n011111111100\n000100100100\n100101001000\n100011011110\n011110100010\n011110111110\n010001010110\n000101000000\n001001100000\n010001101100\n110010110101\n100001000010\n100001001001\n000111000011\n111000100010\n000000011101\n111111000110\n100111100100\n111100011101\n101011110011\n001010110101\n100000000110\n111100011001\n010110010010\n000010010010\n001011111001\n001000011100\n011000011000\n111111110000\n100001110010\n011011110010\n000110011101\n001101001010\n011010100111\n100000011100\n001000111011\n011010100110\n000001111111\n001010010111\n011100001010\n110110001000\n110010101111\n111100010111\n100001111010\n101110010110\n000010110011\n111001010100\n101101110110\n111111111100\n011101101011\n011011110100\n111010100011\n001101000110\n111101111001\n110001111000\n010110000111\n110110100101\n111101011100\n100001000011\n010011101000\n000111110000\n111011110100\n011010111110\n101011001000\n111100110101\n100100001001\n100011110100\n010101010011\n010110011011\n100111001101\n000111001010\n110111011011\n100000111011\n111011000001\n011111100011\n110010000010\n100110101111\n101001111000\n111001111010\n000111111000\n111110100100\n111001111011\n100010110111\n110111001111\n100011001001\n110011001101\n100011101111\n011011110000\n101100011110\n110110111011\n011010100000\n111000000010\n000010010011\n110101101001\n101011011101\n011101100110\n111111000010\n010110100101\n010010011110\n010000101111\n010110101001\n001111010101\n111000101110\n100000010111\n111001000101\n111101101100\n011000000110\n000001110010\n110011010001\n011110011011\n100000010001\n000100100001\n011110001100\n001101011111\n100000000001\n000010011001\n110111000110\n100110110111\n011000110000\n100101000101\n100100111110\n000101010100\n001110100111\n111011001010\n010111001001\n110101001110\n111000100111\n000101011100\n100010111000\n000111110111\n010110010100\n110101100100\n111000011111\n000101001100\n000001011111\n011001111101\n110001111001\n111111110100\n010100111111\n011001100110\n010110101101\n011111011001\n101000010100\n010001100101\n101000100101\n001001010010\n000100011000\n000000000111\n001110011001\n100000001011\n011011101001\n111001000000\n110011100000\n011001100011\n000010011100\n000111000000\n000110011111\n010100011101\n001100010111\n100011000001\n001011000110\n010000011111\n011101001100\n101111011110\n000101001001\n110100101100\n000100010101\n010011001000\n010000010100\n111111010000\n000101000111\n000010010110\n001010000001\n100110110010\n010101100010\n111110010100\n111011111110\n010110110101\n011111000011\n001001001000\n101100001101\n100010101001\n010001101011\n000011011101\n010110011111\n101001001010\n100100001111\n100110100011\n000101001010\n100000100101\n011000100110\n110100000110\n000000010101\n000011110010\n100010010101\n001000100111\n111010000101\n000011000010\n000101001110\n000100110000\n101110010001\n101110100100\n111111001101\n111011101110\n010011000100\n000001001000\n100010111110\n111100101001\n001011111101\n000110000011\n100111111100\n111000000110\n001001011110\n111011110000\n110110000110\n110110011100\n010111111010\n011011001110\n110110001100\n000111100010\n011001100101\n111111000011\n011001111000\n110111010100\n000011111010\n011111101001\n011001011010\n010111101101\n001100100110\n001110101100\n001011011111\n000110001010\n100100001101\n011001101111\n010000100110\n110110010100\n000000110010\n011000101101\n110101111011\n110011111011\n010010001000\n001101110000\n100111100000\n111001011100\n001000110010\n011000011100\n001110010111\n010111011101\n010001110001\n111111101110\n000010111000\n001001000110\n101101100010\n000010000000\n111100100100\n101111011010\n111110011111\n010011110100\n010010010001\n011100011101\n111100000100\n011110011000\n000101100000\n101000111100\n101011110001\n001010000100\n001100101110\n010101010101\n111101110010\n011110100100\n001101100000\n000000110011\n100101100000\n101111100011\n101010101001\n100110110011\n000110100010\n101010000100\n001011010011\n010100110101\n000011101101\n100001001100\n111101101110\n100111101001\n010110111010\n011110000110\n100101011101\n000000001000\n000111001011\n011001000101\n011101001111\n111010001011\n010011011111\n101100001011\n001110110001\n101110110100\n100100011000\n000111010111\n111011111011\n011011100111\n110000110010\n101110110000\n010001111011\n010011111100\n110100110011\n011000111110\n000010111010\n001110001001\n011001100000\n100100100110\n011111001010\n000101000100\n101001010010\n010011101100\n110100101110\n010110001001\n111000011011\n010001110000\n011111011000\n010011000011\n001100001010\n100011100010\n011011111100\n010110101111\n000101100001\n101101100000\n111000110101\n110011010100\n000111011010\n011111010010\n111011111000\n100101110111\n000000111111\n011100110010\n110110011011\n010001011101\n100110110000\n110111110010\n010001111101\n100001101001\n110000111111\n010111110000\n100011001000\n011000101111\n111100100101\n010111010010\n111100110110\n101001100010\n110100010000\n110010111000\n011100010010\n000000001001\n010100011110\n110101010110\n111100100001\n111000010010\n110000010111\n001011100000\n001001010101\n110101101111\n001010010101\n010000110100\n111001011010\n000001111100\n101101011111\n110100111011\n100111010000\n110001110100\n101011000110\n101100111110\n001010010001\n011111101011\n010100001001\n010110100001\n000000110000\n110010111111\n111010000100\n111100001111\n100100110000\n001000110001\n011010001011\n110101111010\n001110000001\n000010100110\n010101111010\n011110100101\n011011100100\n000000011111\n100010011001\n100101000100\n110010011011\n011000000000\n001111111110\n001111010011\n100000110111\n100011011000\n110011111110\n010001000001\n011100011111\n101110001000\n101110000111\n001101100011\n111100100000\n101001110010\n100011110110\n100110101101\n011101100100\n111001011110\n110001101101\n100101101110\n111101001100\n100100100001\n100000011110\n000000000011\n010100010111\n001010010110\n110010110000\n100011110101\n110110110110\n100101101100\n000111011011\n001001001011\n101111010010\n011011010111\n010001100001\n111110101100\n010100100010\n001101101111\n011111100001\n100011011111\n110011111100\n100110001110\n101010100000\n100111011010\n101110101001\n101111001011\n110111000010\n100110001001\n000011111101\n110100010011\n101001000010\n101101011100\n001110010010\n001111000010\n110011101110\n001010011000\n011001000011\n110001101111\n001011001011\n011001111111\n000101010101\n101101100110\n110100101101\n011000111000\n011110100011\n010101110111\n110010001000\n101110100010\n111010001010\n011000001010\n001010110111\n110011111111\n011111101010\n000101110000\n101101000001\n111110111001\n110010111011\n100111101111\n101111000100\n011101110000\n001101010010\n110110011101\n000110000001\n001011111011\n011100001111\n110010101100\n110010010100\n110010100000\n110110000100\n010110011001\n100101101101\n010010010101\n101011111000\n100001001000\n011100011110\n101110010011\n110110001010\n110010110001\n110000000100\n011000000011\n000011111000\n010111000111\n000111000100\n111101100100\n101000101111\n001000000110\n000100000001\n101001100101\n001001111110\n001000010011\n111100001110\n001010111011\n011110011101\n001111101000\n000001110100\n110101000110\n000101000010\n001110101010\n101101011101\n011100101001\n011110000000\n001001101011\n001001011111\n011101111101\n101111100111\n001110110110\n011010110001\n011111000001\n000100101101\n001010010011\n010010110000\n111011101111\n110110000111\n001011110101\n100001101011\n110101100000\n010011111101\n000101110010\n100100111010\n101101101111\n010110111001\n110100110110\n111111001111\n100110010000\n100010100000\n011001101000\n000000111010\n010001100000\n000011001101\n111100011111\n100010111011\n000010100111\n100101000001\n011001001010\n100101010001\n101001001101\n010011101001\n000001000101\n000010011000\n111011100001\n001100111010\n010011011000\n000001011101\n010100111001\n001010110000\n011011101000\n010010111011\n100101100100\n010111000011\n001001111001\n011111011110\n011110111011\n101010010111\n101101111011\n001100011101\n011011010010\n000011000100\n010010110010\n001111011110\n011100011001\n011011101111\n010110101010\n111011010000\n111111010110\n001100110110\n010000110111\n000011110100\n011011000001\n101100101110\n100011001110\n011000010100\n000110001011\n011000000001\n000000111100\n101100110101\n111110010011\n111110101001\n110110101111\n101110110101\n110101111001\n000010001101\n111010101000\n010010100101\n001111101111\n100110100110\n000001010000\n000011110101\n110100111000\n101010111100\n000000010100\n010100010101\n010001100010\n100011010010\n011101001001\n000010101111\n000101000101\n001001101100\n111111100101\n100111111010\n110011101011\n000011100000\n111111011100\n010100001010\n000011100110\n110011111101\n001100000000\n011010101111\n101010101011\n111011000111\n010100110010\n011110110101\n010000011001\n100011010110\n000000001110\n000010101101\n111110100011\n111110010000\n101011101010\n011011001101\n101011111111\n100101101011\n111001000100\n010010000101\n011001010101\n110001100010\n010100001101\n111111101101\n101101000111\n001110110101\n001101000101\n001000100110\n000011011000\n101001001001\n010001001000\n110110111010\n111110011100\n000111111100\n000110101111\n000001110001\n011101101010\n100001001101\n010100010011\n001001001110\n111110110101\n001110001011\n111010101110\n100111000000\n110100000010\n000010111110\n100100000100\n111111001000\n111010001000\n101011100111\n001111111100\n001001101110\n011000001111\n001001100001\n001110000110\n111011011011\n001010101111\n101110110110\n110010000110\n001100010100\n110100111001\n111111110110\n100011001011\n111111000101\n000111010010\n010100100110\n101010110110\n011110110100\n110110101100\n100100111111\n101101110100\n010110101110\n101001101101\n001101010011\n001000100101\n010111010011\n000011110011\n010011111111\n101000000110\n010001111110\n100111010010\n010100010100\n110100001111\n001100000001\n010010110110\n011010011011\n101000010001\n101100010110\n111010011000\n001001101111\n111101010001\n010101111111\n000111010110\n010111100100\n000111101111\n110010100001\n100101111100\n010010010011\n100100001000\n010110000001\n000011000110\n101100110100\n000001100101\n010110101000\n101010100010\n101001110000\n101111000001\n110001111110\n101011010101\n111000010001\n010000101101\n000101010011\n101100011100\n010101000000\n010001110010\n111000001010\n101001011100\n001101111101\n111000101011\n100100000000\n010001011111\n000101000011\n111000011000\n000000100101\n110100001010\n011111111101\n100001010100\n110000011000\n011110011100\n000000110110\n101100100101\n000110001110\n110101110100\n010011111011\n101011100110\n110110010101\n001110011100\n110101110000\n111001001111\n000010101011\n010011100001\n100101010111\n000111100101\n000011001110\n111001000111\n011001100100\n001110001101\n110101010100\n100101100111\n011001000000\n100000110100\n100011101101\n100100110101\n011000110110\n101110011011\n110101100001"

! hardcoded 12, i need to make some defs
nums string-lines [ bin> ] map
[ 12 <iota> <reversed> 0 ] dip
'[
    _ swap '[ _ bit? ] partition [ length ] bi@ > 1 0 ?
    [ 1 shift ] dip bitor
] reduce
dup bitnot 12 bits * .
! 3901196


! swap because 0s win in second loop
nums string-lines [ bin> ] map
11
[ [ over length 1 = ] [ [ '[ _ bit? ] partition longer ] keep 1 - ] until drop ]
[ [ over length 1 = ] [ [ '[ _ bit? ] partition swap shorter ] keep 1 - ] until drop ] 2bi
[ first ] bi@ * .
! 4412188

New Annotation

Summary:
Author:
Mode:
Body: