[Community Puzzle] Lumen


#1

https://www.codingame.com/training/medium/lumen

Send your feedback or ask for help here!

Created by @Sceurpien,validated by @bbb000bbbyyy,@Alain-Delpuch and @DEIZ211.
If you have any issues, feel free to ping them.


#2

Hi,
Lumen was a nice Puzzle to solve.

I had to test until L = 6 to pass the final submission (Medium Hall)
Maybe β€œMedium Hall - Intense Light” could be a better title for this test :slight_smile:

Anyway, cheers!


#3

Seriously, this is an easy puzzle?


#4

Yes, even if I solved it with a BFS, you can solve it in a few lines in Python.


#5

Hello!
I have finished the puzzle with success on all test cases.
However, after I submit the code, two of the post validations fail, saying that I have hard-coded values in it. I am pretty sure I do not have any.

Can someone help me with this to figure out what is wrong?


#6

We’ll need more information for us to help you mate :slight_smile:

Which validators ? Might explain a little your algorithm etc… !


#7

You’re right, so the post tests that fail are No 5 - THEY have a medium cellar and
No 6 - THEY have a large cellar.

As for my code, I create a table of objects (with properties like HasCandle and LightIntensity). Then I have a loop on those objects and a function to change light values on the surrounding blocks, if the current block has a candle.

All test cases are a success. On post validations only the 5 and 6 are a fail but cannot seem to understand why.


#8

Is it recursive ? You might have an overflow ?


#9

It is not recursive.
Can I show you the code?


#10

yep send via private message !


#11

Here is part of my private answer to @KainV in private message. it could help some :


L is not always equals to 2 or 3. it could be 1 it could be 9…

for example in my code i do something like this:

recursiveFunction(cells, i, j, lightPower) {
	cells[i][j] = lightPower;
	if lightPower <= 1
        stop here recursion

	if i is in cells bounds and if the lightpower in the cell is < than the current light minus one
		recursiveFunction(cells, i(-/+)1, j, lightPower-1)
	if j is in cells bounds and if the lightpower in the cell is < than the current light minus one
		recursiveFunction(cells, i, j(-/+)1, lightPower-1)

	if i and j are in cells bounds and if the lightpower in the cell is < than the current light minus one
		recursiveFunction(cells, i(-/+)1, j(-/+)1, lightPower-1)
}

In order to check like this around the cell :

β”Œβˆ’βˆ’βˆ’β”β”Œβˆ’βˆ’βˆ’β”β”Œβˆ’βˆ’βˆ’β”
β”‚ \ β”‚β”‚ | β”‚β”‚ / β”‚
β””βˆ’βˆ’βˆ’β”˜β””βˆ’βˆ’βˆ’β”˜β””βˆ’βˆ’βˆ’β”˜
β”Œβˆ’βˆ’βˆ’β”β”Œβˆ’βˆ’βˆ’β”β”Œβˆ’βˆ’βˆ’β”
β”‚ βˆ’ β”‚β”‚ βˆ† β”‚β”‚ βˆ’ β”‚
β””βˆ’βˆ’βˆ’β”˜β””βˆ’βˆ’βˆ’β”˜β””βˆ’βˆ’βˆ’β”˜
β”Œβˆ’βˆ’βˆ’β”β”Œβˆ’βˆ’βˆ’β”β”Œβˆ’βˆ’βˆ’β”
β”‚ / β”‚β”‚ | β”‚β”‚ \ β”‚
β””βˆ’βˆ’βˆ’β”˜β””βˆ’βˆ’βˆ’β”˜β””βˆ’βˆ’βˆ’β”˜

Good luck ! :slight_smile:


#12

I have the same problem as KainV
This is my first script in Python and I can’t make it work
I’ll try with another language

According to the constraints

0 < L < 10


#13

Yes my bad, all I was saying is that L is variable ! ^^
You might want to explain a little your problem / your algorithm ?

EDIT : I edited my previous post !


#14

Thanks for asking but I just submited my code in JavaScript and I scored 100%
Let’s fix Python version :weary:

EDIT : Fixed. Looks like I forgot +1 in range()'s stop argument


#15

the sentence β€œIf a spot is touched by two candles, it will have the larger β€œlight” it can have” was confusing. I assumed it meant that if a spot has 2 or more neighbouring candles it would get the light level of a candle. In testcase 2, the X right in the middle of the matrix, between the candles, has a light level of 2 and not 3.


#16

I solved it without any consideration for light level.


#17

Same thing here. works great, have everything in variables, fails those same two tests on submission.


#18

I had the same problem with the 5 and 6 test. As a result, it turned out that I was going beyond the bound of the array.


#19

Same problem here with 5 and 6 at the validation. I m not sure to understand correctly the part about light when there is two or more candles. to be sure to understand. What is the results with the following inputs? my solution give 5 but i wonder if the correct answer is 0… if so, a test case should be added.
l=4
n=5
XXXXX
CXXXX
XXXXX
CXXXX
XXXXX


#20

consider this :
With light = 6

CXXXXXXC
65433456

instead of

CXXXXXXC
65432106

When two overlap, you have to keep the highest light value

Right from my code :

X X X X X 
C X X X X 
X X X X X 
C X X X X 
X X X X X
----------
3 3 2 1 0 
4 3 2 1 0 
3 3 2 1 0 
4 3 2 1 0 
3 3 2 1 0
----------
5