43
8
The Hourglass
This hourglass has 60 "sands of time", and it completely fills each chamber. The clock is 19 characters wide and 13 characters in height. Each chamber has 5 rows of sand and there is a row in the centre that can hold 1 sand. The top row can hold 17 sands, the next one 15 and so on (see below). Sands fall in to the bottom chamber at the rate of one sand per second.
START 3 SECONDS LATER 38 SECONDS LATER
███████████████████ ███████████████████ ███████████████████
█.................█ 17 █.............. █ 14 █ █ 0
██...............██ 15 ██...............██ 15 ██ ██ 0
███.............███ 13 ███.............███ 13 ███....... ███ 7
█████.........█████ 09 █████.........█████ 09 █████.........█████ 09
███████.....███████ 05 ███████.....███████ 05 ███████.....███████ 05
█████████.█████████ 01 █████████.█████████ 01 █████████.█████████ 01
███████ ███████ ███████ . ███████ ███████ . ███████
█████ █████ █████ . █████ █████ . █████
███ ███ ███ . ███ ███.... ███
██ ██ ██ ██ ██...............██
█ █ █ █ █.................█
███████████████████ ███████████████████ ███████████████████
The Challenge
Display the hourglass (no numbers or headings are required) after a certain period of time (0 ≤ t ≤ 60).
Coding Rules
- The hourglass should look exactly as shown here. You may replace the
█
character and/or the.
character with whatever you like to fit your language (Unicode, ASCII compatibility issues). - The input should be a number such as 45 or 7. Display the clock after these many seconds.
- The output can either be displayed or saved to a file. No extra text or labels as shown above are required - just the hourglass is all we need.
- If the user enters t > 60, you don't have to handle the error.
Points
- Shortest code wins.
I don't know if it's just me, but the hourglasses looks completely different in the editor than in the post itself. That's probably because the █ character doesn't get displayed with the proper width. – Dennis – 2015-06-08T06:53:39.277
1Does a grain of sand touch the current layer, then align to the left one second later? – xnor – 2015-06-08T07:25:11.450
@xnor You are free to choose. – Renae Lider – 2015-06-08T08:34:17.647
2What should be the output for t==59? – edc65 – 2015-06-08T09:07:26.903
3Congrats on making the Stack Exchange Hot Network Questions list! – Alex A. – 2015-06-09T15:06:26.040
@AlexA. Oh that is great, I am humbled. hehe.. but I don't know what " Hot Network Questions" are. Where can I find that? – Renae Lider – 2015-06-09T21:42:30.910
@RenaeLider: They appear along the right side of the page in the form of a site icon and a question title, visible from all Stack Exchange sites. You can also see the list on the Stack Exchange questions homepage.
– Alex A. – 2015-06-09T21:56:21.453Interesting. Just 7 answers. The slightly similar Code Golf: Hourglass on [SO] was more popular.
– manatwork – 2015-06-17T13:40:09.8201
This is not really an answer, as it doesn't fit the specs, but take a look here for a submission in Desmos. (Press the play button and set the speed to 0.15x for ~1 unit/second)
– Conor O'Brien – 2015-10-02T13:29:41.930