Blog Post

Advent of Code #3 – Part 2

,

Adding to my solution for #3 part 2, I finally got it, but I paid the price for not adding the “0, 0” to the data set and just assumed I should add one. Bad assumption! Wound up being off by 1 and it took too long to figure that out.

select distinct xvalue, yvalue from 
(
select
 sum (xchange) over (partition by santa order by rowid) as XValue,
 sum (ychange) over (partition by santa order by rowid) as YValue,
 Santa
from 
(
select 
 rowid, 
 DoThis,
 case when DoThis = '^' then 1 when DoThis = 'v' then - 1 else 0 end as YChange,
 case when DoThis = '>' then 1 when DoThis = '<' then - 1 else 0 end as XChange,
 RowID % 2 as Santa
from directions2
) a
) b

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating