Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: SyntaxException => index out of bounds: the len is 0 but the index is 0 #17162

Open
BohuTANG opened this issue Jan 3, 2025 · 0 comments

Comments

@BohuTANG
Copy link
Member

BohuTANG commented Jan 3, 2025

Summary

SQL from https://databasearchitects.blogspot.com/2024/12/advent-of-code-2024-in-pure-sql.html:

with recursive aoc10_input(i) as (select '
89010123
78121874
87430965
96549874
45678903
32019012
01329801
10456732
'),
lines(y,line) as (
   select 0, substr(i,1,position('\n' in i)-1), substr(i,position('\n' in i)+1)
   from aoc10_input
   union all
   select y+1,substr(r,1,position('\n' in r)-1), substr(r,position('\n' in r)+1)
   from lines l(y,l,r) where position('\n' in r)>0
),
field(x,y,v) as (
   select x,y,ascii(substr(line,x::integer,1))-48
   from (select * from lines l where line<>'') s, lateral generate_series(1,length(line)) g(x)
),
paths(x,y,v,sx,sy) as (
   select x,y,9,x,y from field where v = 9
   union all
   select f.x,f.y,f.v,p.sx,p.sy
   from field f, paths p
   where f.v=p.v-1 and ((f.x=p.x and abs(f.y-p.y)=1) or (f.y=p.y and abs(f.x-p.x)=1)) and p.v>0),
results as (select * from paths where v=0),
part1 as (select distinct * from results)
select (select count(*) from part1)  as part1, (select count(*) from results) as part2

Error:

1104: index out of bounds: the len is 0 but the index is 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant