Currently at my work we moved to a new building. It's supposed to be state of the art and has automatic lights, automatic roll-down shutters, and is now known as the most eco-friendly building in this town.
However, it doesn't really work all that well.. The roll-down shutters sometimes go down on cloudy days and up when the sun starts to shine, and the lights sometimes cause disco effects by alternating turning on and off every 5-10 minutes. Also, we don't have any manual way of controlling these roll-down shutters, nor the temperature, BUT we do have a remote for the lights.
These remotes however came without instruction manual and contain little over 20 buttons doing all kind of stuff except for what you seem to want..
PS: I wrote this challenge 1.5 months ago in the Sandbox. Currently we, kinda, know how the remotes work..
One big advantage about this building, it's 30+ degrees Celcius outside, but inside it stays the same 21 room temperature at all time.
So, that was the intro, and the remote control for the lights inspired this challenge.
Let's say we initially have a lamp turned off:
Then we push all kind of buttons and output the state of the lamp afterwards.
We use the following numbers for the different functions of the remote control for the lamp. When a minus symbol is in front of that number, we do the opposite.
2= Increase strength by 25%;
-2= Decrease (dim) strength by 25%.
3= Increase spread by 50%;
-3= Decrease spread by 50%.
4= Toggling the type of light.
So, this is all pretty vague, so let's go a little more in depth what each thing means:
-1 (OFF) is pretty obvious, and
1 will go to the initial ON-state (50% for
2 and 50% for
// // L ==== \\ \\
-2 is how far the light travels (
== is appended for every 25%):
0% (equal to a light bulb that is OFF) L 25% L == 50% L ==== 75% L ====== 100% L ========
-3 is how far the light spreads:
0%: L ==== 50%: // // L ==== \\ \\ 100%: || // ||// L ==== ||\\ || \\
3 are both at 100%, you'll have this state:
|| // || // || // ||// L ======== ||\\ || \\ || \\ || \\
4 is to toggle the type of light.
Default: // L == \\ After toggling (note the single space before '/' instead of two): / L -- \
You will receive an input containing the possible button-presses. For example:
The state of the light lamp after all the buttons of the input are sub-sequential pressed. So with the example input above, we have the following output:
- The input only contains
1234-(and never a
- You can never go below 0% or above 100%. If a number would increase/decrease beyond these boundaries you can ignore it.
- When the lamp is turned off, you can ignore any actions and when turned back on again it resets back to the initial ON-state (50% for both
3, and default
4). For example:
12-1-341will just print the initial ON-state mentioned above. (TIP: You can ignore everything before the final
1of the input - excluding
- Trailing spaces equal to the length of the light or a single trailing new line is uninhibited. Adding extra unnecessary new lines isn't however.
- You are allowed to take the input as a list of integers instead of a single string. So instead of
12-34, you can have
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
- Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
12-34 L ------ 12-1-341 // // L ==== \\ \\ 14-3224333-2 || // || // ||// L ====== ||\\ || \\ || \\ 142-1-314-3-322 L -------- 1324-2-3 / / L ---- \ \ 134 | / |/ L ---- |\ | \ 1-2-2-214-3-3-3 L ----