Skip to content

Instantly share code, notes, and snippets.

@remy
Created December 3, 2025 16:26
Show Gist options
  • Select an option

  • Save remy/77f2283863eb7769dfd8ea6fd36cd032 to your computer and use it in GitHub Desktop.

Select an option

Save remy/77f2283863eb7769dfd8ea6fd36cd032 to your computer and use it in GitHub Desktop.
jq -R -rn -f ./2-b.jq ./2.input
[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