Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Golfscript - 136 Chars (Fits in a Tweet)</h1> <p>Be sure not to have a newline after the % for the input<br> eg<br> <code>$ echo -n 3 71%|./golfscript.rb hourglass.gs</code></p> <p>You can animate the hourglass like this: </p> <p><code>$ for((c=100;c&gt;=0;c--));do echo -n "15 $c%"|./golfscript.rb hourglass.gs;echo;sleep 0.1;done;</code></p> <p><strong>Golfscript - 136 Chars</strong><br> Make sure you don't save it with an extra newline on the end or it will print an extra number</p> <pre><code>);' ': /(~: ;0=~100.@- .**\/:t;'_':&amp;&amp; *.n ,{:y *.'\\'+{[&amp;'x':x]0t(:t&gt;=}:S~ (y-,{;S\+S+.}%;'/'++\+}%.{&amp;/ *}%\-1%{-1%x/ *&amp;/x*}%) /&amp;[*]++n* </code></pre> <p><strong>Golfscript - 144 Chars</strong></p> <pre> );' ':|/(~:^.*:X ;0=~100.@-X*\/ X'x':x*'_':& @*+:s;&&&+ ^*n^,{:y |*.[92 ]+{s [) \# :s;] }:S~^( y-,{;S\+ S+.}%;'/'+ +\+}%.{&/|*} %\-1%{-1%x/|*& /x*}%)|/&[*]++n* </pre> <p><strong>How it works</strong><br> First do the top line of underscores which is <code>2n+1</code> Create the top half of the hourglass, but use '_' chars instead of spaces, so for the 3 71% we would have.</p> <pre><code>\x__xx/ \xxx/ \x/ </code></pre> <p>Complete the top half by replacing the "_" with " " but save a copy to generate the bottom half</p> <p>The bottom half is created by reversing the whole thing</p> <pre><code> /x\ /xxx\ /xx__x\ </code></pre> <p>Replacing all the 'x' with ' ' and then then '_' with 'x'</p> <pre><code> / \ / \ / xx \ </code></pre> <p>Finally replace the ' ' in the bottom row with '_'</p> <pre><code> / \ / \ /__xx_\ </code></pre> <p>Roundabout but for me, the code turned out shorter than trying to generate both halves at once</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload