Damn, so I learned today that Julia has both the / operator AND the ÷ operator! The / operator will produce a float, regardless of the types of the inputs (so 2/5 returns 2.5) but ÷ does integer division! So 2÷5 returns 2.

Anyways, Part 1 was brute-forceable, on my machine it ran in <0.5 seconds.

But when I attempted to brute-force Part 2...well, it ran in 2 minutes 45 seconds. It works, I guess? I can't help thinking there's a smarter solution to this.

Anyways, my part 2 code:

function most_powerful_region(grid_num)max_power=nothingmax_x=0max_y=0max_block_size=0forblock_sizein1:300upper_bound=300-block_size+1forxin1:upper_boundforyin1:upper_boundp=power_level_block(x,y,grid_num,block_size)ifmax_power==nothing||p>max_powermax_power=pmax_x=xmax_y=ymax_block_size=block_sizeendendendendreturn(max_x,max_y,max_block_size)endfunction power_level_block(topx,lefty,grid_num,block_size)power=0forxintopx:topx+(block_size-1)foryinlefty:lefty+(block_size-1)p=power_level(x,y,grid_num)power+=pendendreturnpowerendfunction power_level(x,y,grid_num)rack_id=x+10power=rack_id*ypower+=grid_numpower*=rack_idifpower>=100power=(power÷100)%10# WTF: the / does float division but ÷ does integer division?!elsepower=0endpower-=5returnpowerend

## re: AoC Day 11: Chronal Charge VIEW POST

FULL DISCUSSIONDamn, so I learned today that Julia has both the

`/`

operator AND the`÷`

operator! The`/`

operator will produce a float, regardless of the types of the inputs (so`2/5`

returns`2.5`

) but`÷`

does integer division! So`2÷5`

returns`2`

.Anyways, Part 1 was brute-forceable, on my machine it ran in <0.5 seconds.

But when I attempted to brute-force Part 2...well, it ran in 2 minutes 45 seconds. It works, I guess? I can't help thinking there's a smarter solution to this.

Anyways, my part 2 code: