+ 13
[ASSIGNMENT] The LED Problem
In one LED Bulb there are 3 LED lights:Red, Green and Blue. See the colour combinations: https://ibb.co/bJCpGx Red LED stays ON for R seconds Green LED stays ON for G seconds Blue LED stays ON for B seconds Similarly they stay OFF for same R, G, B seconds. Initially,the LEDs are OFF. Challenge: Given the total number of seconds T, find the number of seconds Red, Green, Blue, Yellow,Cyan,Magenta,White,Black(No Light) stays ON. SampleInput: 12 2 3 5 SampleOutput: 1 1 1 3 2 2 0 2 Ill: https://ibb.co/dkWkOc
13 Answers
+ 6
My Solution: https://code.sololearn.com/cLK33a4u16jl/?ref=app
P. S: Not the best answer though
+ 18
For 3 LED (red, green, blue) :
https://code.sololearn.com/c5snEc2RgU72/?ref=app
For 'n' number of LED:
https://code.sololearn.com/cHSfEk1582uE/?ref=app
https://code.sololearn.com/cd2l326c832Q/?ref=app
+ 10
Nice challenge, Vivek !
https://code.sololearn.com/cnu9XJQxO14s/?ref=app
An alternative with visualisation of the cycle, using numpy arrays
https://code.sololearn.com/c2MDuz3HSW4s/#py
+ 9
Check this one liner. Also adds a clearer output.
https://code.sololearn.com/c8zi5zXN8EpL
+ 8
@VcC It looks super cool!
And especially for you I reduced my code to oneliner (2 lines in fact), however now only color codes left and the code itself looks overcomplicated, but it still works for any number of LED (!) :
https://code.sololearn.com/cB3DEYXbf4nf/?ref=app
+ 7
This is an extended version, which can operate with any number of individual LED inside one LED bulb. However, only for 3 LEDs colors are returned by name otherwise it is a color code:
https://code.sololearn.com/cSSqHowN6JYs/?ref=app
Input example for 5 LED (32 different colors): 1000 2 3 5 7 4
Feel free to test it and inform me about any bugs you have found!
+ 7
Hello all, here the first code that deals with time as a floating number and not as an integer. At least here time is continuos ;) Feel free to enter decimals to the time of the leds. Works for any number of leds.
https://code.sololearn.com/cGgmtn40ZHv8/?ref=app
+ 6
https://code.sololearn.com/cDjs2M26cfU1/?ref=app
+ 3
@Nevfy Vivek Sivaramakrishnan Men, so many lines...And dont tell me about the complexity, i know :-)
+ 1
@~ swim ~ Look into my code, I had to deal with floating precision again :) this time the answer was much simpler.