Challenge 20 - Am I Missing Something?


I wrote a code that when tested provided the following result (see below) but it says “Your code ran but did not produce the correct result.” Am I missing something else that needs to be done?



Would be great if you could show your code at least the screenshot doesn’t tell much.


Hi @vanessalillymarie,

Your output looks good, but I’m not sure how you are exporting it exactly.

My idea was to reuse the already existing GRID (so I know exactly the number of columns and rows), copy it, and change the values using the howDangerous() method created earlier. Then return it.

Hope this helps!



I’m having the same issue. From what I’m seeing my output is correct but it’s still saying “Your code ran but did not produce the correct result.”


Actually @vanessalillymarie the last row that you’re returning looks incorrect, it shouldn’t be all zeroes, you might need to loop something one more time?


I’m also getting my last row as zeroes, what would I need to loop one more time ?


For my solution I had a for loop that was mapping each row through the howDangerous function, I was thinking that if you have a row that’s coming out as all zeroes then that might mean the map isn’t looping over the last row of the array.

I also got mine working, I was predefining the size of the array to return and had the width and the height backwards. Couldn’t tell at first since ours is a 10x10 grid, so I’m guessing they have a test that uses a non-square grid.


@jeff Did you use the map function?


I wasn’t handling cases where the coords are 3 characters (e.g “A10”). Fixed that in my lightCell function. My arrays are correct but still get “Your code ran but did not produce the correct result.”, not sure why.


I did, yeah. What I did was create a new grid that has the coordinates in it instead of the grd values (eg. the 2x2 version of the grid is [[A1,A2],[B1,B2]]), used a loop, and then for each subarray I mapped the howDangerous function onto it. It was tricky trying to figure out a way to use map with a 2D array but wrapping it in a for loop did the trick.


Cool thanks! I got mine to work after changing my nested for loop to use the map function instead. I ended up rewriting the howDangerous function to not take a coordinate (like ‘A1’) but just take the cell’s value instead.