Fifty Shades of Grey
Boys and girls are excited to see Fifty Shades of Grey on the silver screen, we just want to code without being bothered, so here's a challenge to pick our brain.
You have to:
- Print on the screen fifty squares filled each with a different shade of grey
- If your language of choice lacks image processing capabilities, you could output an image file
- Squares must be visible, at least 20 x 20 pixels
- You cannot use random numbers unless you make sure each shade is unique.
- You cannot connect to any service over any network
- You cannot read any files in your program.
- You cannot use any libraries out of the standard libraries of your language of choice.
This is code golf so shortest code wins.
Can we also generate an image file if our language lacks image processing capabilities?
@BWG: presumably Mukul means because C++ has no standard means to access a screen. Terminal, yes, and you could do it assuming certain terminal properties (background colour control codes) and the aspect ratio of the terminal characters (to get a square).
@SteveJessop I didn't read the request fully, but couldn't you just write a bitmap? The header is pretty trivial, and the rest is just plain bytes.
@randomra If I could understand what "The interpreter finds the edge of the current colour block which is furthest in the direction of the DP. (This edge may be disjoint if the block is of a complex shape.) The interpreter finds the codel of the current colour block on that edge which is furthest to the CC's direction of the DP's direction of travel. (Visualise this as standing on the program and walking in the direction of the DP; see table at right.)" meant, I would be working on a Piet submission
@BWG: that's what the CJam answer below does, so of course you *could* do that. It's clearly not what the question says, but I think the questioner has been overruled by the voters.
@randomra ask and you shall receive: http://codegolf.stackexchange.com/questions/45736/fifty-shades-of-grey/46877#46877
Do black and white count as shades of grey? Or should they be excluded?
@BWG Oh...I was so much immersed in array handling that I forgot to use graphical header files....LOL I was still thinking of ASCII characters....:P
@Steffen sorry I thought that was the shortest answer that didn't break any of the rules, what is the answer that you mention?