Get ranges

This commit is contained in:
bdnugget committed 2025-12-08 14:27:03 +01:00
1 parent 94a1bed445
commit 80272b3747
3 files changed
+14 -4

No files matched your search

+1
View File
@@ -0,0 +1 @@
11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124
+1
View File
@@ -0,0 +1 @@
119-210,907313-1048019,7272640820-7272795557,6315717352-6315818282,42-65,2234869-2439411,1474-2883,33023-53147,1-15,6151-14081,3068-5955,65808-128089,518490556-518593948,3535333552-3535383752,7340190-7548414,547-889,34283147-34389716,44361695-44519217,607492-669180,7071078-7183353,67-115,969-1469,3636264326-3636424525,762682710-762831570,827113-906870,205757-331544,290-523,86343460-86510016,5536957-5589517,132876-197570,676083-793651,23-41,17920-31734,440069-593347
+12 -4
View File
@@ -1,12 +1,20 @@
#!/usr/bin/env bash
set -Eeuo pipefail
trap 'echo "SHIEEEET at line $LINENO" >&2' ERR
# Advent of Code day 02
main() {
:
local line
line=$(< example.txt)
IFS=',' read -ra ranges <<< "$line"
for r in "${ranges[@]}"; do
IFS='-' read -r start end <<< "$r"
for ((i=start; i<=end; i++)); do
echo "$i"
done
done
}
main "$@"