Created
December 3, 2025 16:26
-
-
Save remy/77f2283863eb7769dfd8ea6fd36cd032 to your computer and use it in GitHub Desktop.
jq -R -rn -f ./2-b.jq ./2.input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [inputs | split(",")] | flatten | map(select(. != "")) | # format | |
| def repeatstr($offset; $n): | |
| .[0:$offset] as $val | | |
| [range($n) | $val] | join("") | |
| ; | |
| def invalid: | |
| . as $value | | |
| length as $length | | |
| # get the comparison ranges | |
| [ | |
| range(2; length | ceil + 1) | | |
| ($length / .) | | |
| select(. == floor) | | |
| select( | |
| . as $i | | |
| $value | . == repeatstr($i; $length / $i) | |
| ) | |
| ] | length > 0 | |
| ; | |
| map( | |
| split("-") | | |
| map(tonumber) | | |
| range(.[0]; .[1]+1) | | |
| tostring | | |
| select(invalid) | | |
| tonumber | |
| ) | |
| | add |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment