- Produce a page that has a background of any hexadecimal colour.
- It must contain a form and submit button that when pressed, rotates the background colour, up to #FFFFFF and back down to #000000 and then back up to #FFFFFF in an infinite cycle.
- The colour must take red to one extreme, before applying to Green, then Blue,
- The colour must move a maximum of 18 (in decimal, 12 in hexadecimal) units per iteration.
[Challenge] Colour rotation
Moderator: General Moderators
-
SimonMayer
- Forum Commoner
- Posts: 32
- Joined: Wed Sep 09, 2009 6:40 pm
[Challenge] Colour rotation
Here's a challenge, dished up solely for the sake of a puzzler's own enjoyment and not for any practical use. I hope it stimulates some thought.
Re: [Challenge] Colour rotation
Why 18? 256 doesn't divide evenly into it. Or is that the point?
-
SimonMayer
- Forum Commoner
- Posts: 32
- Joined: Wed Sep 09, 2009 6:40 pm
Re: [Challenge] Colour rotation
Yes, it was deliberate. I did specify a maximum of 18, so you can use 16 if you prefer.tasairis wrote:Why 18? 256 doesn't divide evenly into it. Or is that the point?
18 offers a performance advantage, because it will take less iterations to complete the cycle, but obviously requires a bit more consideration to get it right.
Re: [Challenge] Colour rotation
My answer: http://snydev.com/temp-files/devnet-cha ... otator.php
Edit: This post was recovered from search engine cache.
Edit: This post was recovered from search engine cache.
Last edited by McInfo on Mon Jun 14, 2010 5:40 pm, edited 1 time in total.
-
SimonMayer
- Forum Commoner
- Posts: 32
- Joined: Wed Sep 09, 2009 6:40 pm
Re: [Challenge] Colour rotation
That's good, but it needs to increment more slowly.McInfo wrote:My answer: http://snydev.com/temp-files/devnet-cha ... otator.php
#000000 would have to go up a maximum of 18 units per iteration: #120000, #240000, #360000...;
The challenge here, particularly would be it has to effectively count when it reaches FF and safeguard against it going any higher.
-
SimonMayer
- Forum Commoner
- Posts: 32
- Joined: Wed Sep 09, 2009 6:40 pm
Re: [Challenge] Colour rotation
That almost seems to do it. It just doesn't quite follow the correct cycle. From #FFFFFF, it appears to reduce in the order Blue, Green, Red. It would still need to work in the order Red, Green, Blue for the deduction too.
I hadn't considered doing it with just one button click or Javascript. I was thinking PHP and a series of clicks. That's very interesting.
Being picky, I point out it doesn't actually have a form, just a submit button, but that's a minor point.
Re: [Challenge] Colour rotation
You can change the amount of incrementation by changing the "step". Its range is 1 to 255.SimonMayer wrote:That's good, but it needs to increment more slowly.
?step=18&color=000000
Should the step be limited to the range 1 to 18? If so, why?
Edit: This post was recovered from search engine cache.
Last edited by McInfo on Mon Jun 14, 2010 5:42 pm, edited 1 time in total.
Re: [Challenge] Colour rotation
I liked this one quite a bit. I'm still playing with it right now actually lol.McInfo wrote:My answer: http://snydev.com/temp-files/devnet-cha ... otator.php
-
SimonMayer
- Forum Commoner
- Posts: 32
- Joined: Wed Sep 09, 2009 6:40 pm
Re: [Challenge] Colour rotation
My apologies, I hadn't noticed that you could increment in smaller numbers.McInfo wrote:You can change the amount of incrementation by changing the "step". Its range is 1 to 255.SimonMayer wrote:That's good, but it needs to increment more slowly.
?step=18&color=000000
Should the step be limited to the range 1 to 18? If so, why?
There is no reason why the code should be limited, but to add a level of intricacy to the challenge, I was hoping that someone would make it handle when increments of 18 reached FF.
You have done this and so you have passed the challenge.
I'm afraid I haven't made any badges for this challenge, but I commend you for meeting and exceeding the requirements.