why it doesn't work? thanks!
Code: Select all
Moderator: Board moderators
Code: Select all
Hellowyvmak wrote:i used recursion. though i guess there're better methods than mine. (i heard somebody use looping)
my algorithm:
go from the top-row,
- for each one in top-row, you can switch or not switch
for the rest of the rows,
- the upper row would determine whether you can switch or not. ie. if the upper row is off, you cannot switch; otherwise you must switch.
Code: Select all
SOLUTION_NUMBER=roundup( log2 N )