70
\$\begingroup\$

Dennis puts in a huge amount of effort for this community, including as moderator, language designer, and provider of TIO.

Unfortunately, his four-year-old daughter has caught a cold, so let us all help him keep track of her recovery (may it be speedy) by providing him with a thermometer:

.-----------.
|           |
|           |
'-.       .-'
.-'   -   '-.
|107.6- 42.0|
|106.7- 41.5|
|105.8- 41.0|
|104.9- 40.5|
|104.0- 40.0|
|103.1- 39.5|
|102.2- 39.0|
|101.3- 38.5|
|100.4- 38.0|
| 99.5- 37.5|
| 98.6- 37.0|
| 97.7- 36.5|
| 96.8- 36.0|
| 95.9- 35.5|
| 95.0- 35.0|
'---. - .---'
    | - |
    |---|
    |   |
    '---'

Since Dennis does not have much time to read code, you must keep yours as short as possible.

\$\endgroup\$
  • 11
    \$\begingroup\$ The shape reminds me more of a pregnancy test ._. \$\endgroup\$ – Magic Octopus Urn Apr 26 '17 at 19:08
  • 3
    \$\begingroup\$ @carusocomputing That he puts in a huge amount of effort. Maybe all that he does is really easy for him. Did he ever mention it being hard? \$\endgroup\$ – Adám Apr 26 '17 at 19:18
  • 7
    \$\begingroup\$ Aww, hope she gets well. Anyways, I'm giving a +100 bounty to who makes a functional thermometer! :P \$\endgroup\$ – lol Apr 26 '17 at 22:55
  • 4
    \$\begingroup\$ @SIGSEGV Try it online! - Source \$\endgroup\$ – Adám Apr 26 '17 at 23:11
  • 4
    \$\begingroup\$ @SIGSEGV it'd be a menace. \$\endgroup\$ – Magic Octopus Urn Apr 27 '17 at 18:05

17 Answers 17

16
\$\begingroup\$

Jelly, 90 89 84 83 82 bytes

-1 byte thanks to Erik the Outgolfer (replace 10 with )

15r1×€9,5+“£Ȧ“¡^’d⁵Dj€€”.j€⁾- Uz⁶ZUj@€⁾||
“¡ẹƭgụḌẊṘgYƊxyẓṡƝçƤ5ȥṭ’ṃ“.| '-”s7ŒBs5j¢Y

Try it online!

How?

15r1×€9,5+“£Ȧ“¡^’d⁵Dj€€”.j€⁾- Uz⁶ZUj@€⁾|| - Link 1, body: no arguments
15r1                                      - inclusive range(15,1)      = [15,14,...,2,1]
      9,5                                 - pair nine with five        = [9,5]
    ×€                                    - multiply for €ach          = [[135,75],[126,70],...,[18,10],[9,5]]
          “£Ȧ“¡^’                         - list of base 250 numbers   = [941,345]
         +                                - addition                   = [[1076,420],[1067,415],...,[959,355],[950,350]]
                 d⁵                       - div&mod 10                 = [[[107,6],[42,0]],[[106,7],[41,5]],...,[[95,9],[35,5]],[[95,0],[35,0]]]
                   D                      - convert to decimal lists   = [[[[1,0,7],6],[[4,2],0]],[[[1,0,6],7],[[4,1],5]],...,[[[9,5],9],[[3,5],5]],[[[9,5],0],[[3,5],0]]]
                       ”.                 - literal '.'
                    j€€                   - join €ach for €ach         = [[[1,0,7,'.',6],[4,2,'.',0]],[[1,0,6,'.',7],[4,1,'.',5]],...,[[9,5,'.',9],[3,5,'.',5]],[[9,5,'.',0],[3,5,'.',0]]]
                           ⁾- <space      - literal ['-',' ']
                         j€               - join €ach                  = [[1,0,7,'.',6,'-',' ',4,2,'.',0],[1,0,6,'.',7,'-',' ',4,1,'.',5],...,[9,5,'.',9,'-',' ',3,5,'.',5],[9,5,'.',0,'-',' ',3,5,'.',0]]
                              U           - upend (reverse each)       = [[0,'.',2,4,' ','-',6,'.',7,0,1],[5,'.',1,4,' ','-',7,'.',6,0,1],...,[0,'.',5,3,' ','-',9,'.',5,9],[0,'.',5,3,' ','-',0,'.',5,9]]
                               z⁶         - transpose space filler     = [[0,5,...,5,0],['.','.',...,'.','.'],[2,1,...,5,5],[4,4,...,3,3],[' ',' ',...,' ',' '],['-','-',...,'-','-'],[6,7,...,9,0],['.','.',...'.','.'],[7,6,...,5,5],[0,0,...,9,9],[1,1,...,' ',' ']]
                                 Z        - transpose                  = [[0,'.',2,4,' ','-',6,'.',7,0,1],[5,'.',1,4,' ','-',7,'.',6,0,1],...,[5,'.',5,3,' ','-',9,'.',5,9,' '],[0,'.',5,3,' ','-',0,'.',5,9,' ']]
                                  U       - upend                      = [[1,0,7,'.',6,'-',' ',4,2,'.',0],[1,0,6,'.',7,'-',' ',4,1,'.',5],...,[' ',9,5,'.',9,'-',' ',3,5,'.',5],[' ',9,5,'.',0,'-',' ',3,5,'.',0]]
                                      ⁾|| - literal ['|','|']
                                   j@€    - join €ach (reversed @rgs)  = [['|',1,0,7,'.',6,'-',' ',4,2,'.',0,'|'],['|',1,0,6,'.',7,'-',' ',4,1,'.',5,'|'],...,['|',' ',9,5,'.',9,'-',' ',3,5,'.',5,'|'],['|',' ',9,5,'.',0,'-',' ',3,5,'.',0,'|']]
                                          -                  effectively ["|107.6- 42.0|","|106.7- 41.5|","|105.8- 41.0|","|104.9- 40.5|","|104.0- 40.0|","|103.1- 39.5|","|102.2- 39.0|","|101.3- 38.5|","|100.4- 38.0|","| 99.5- 37.5|","| 98.6- 37.0|","| 97.7- 36.5|","| 96.8- 36.0|","| 95.9- 35.5|","| 95.0- 35.0|"]

“¡ẹƭgụḌẊṘgYƊxyẓṡƝçƤ5ȥṭ’ṃ“.| '-”s7ŒBs5j¢Y - Main link: no arguments   (using "..." below to represent lists of characters)
“¡ẹƭgụḌẊṘgYƊxyẓṡƝçƤ5ȥṭ’                  - base 250 number     =  1694125525350532761476179586378844141697690917975
                        “.| '-”          - literal ['.','|',' ',"'",'-']
                       ṃ                 - base decompression  =  ".------|      |      '-.    .-'   -'---. -    | -    |--    |      '--"
                               s7        - split into 7s       =  [".------","|      ","|      ","'-.    ",".-'   -","'---. -","    | -","    |--","    |  ","    '--"]
                                 ŒB      - bounce (vectorises) =  [".-----------.","|           |","|           |","'-.       .-'",".-'   -   '-.","'---. - .---'","    | - |    ","    |---|    ","    |   |    ","    '---'    "]
                                   s5    - split into 5s       = [[".-----------.","|           |","|           |","'-.       .-'",".-'   -   '-."],["'---. - .---'","    | - |    ","    |---|    ","    |   |    ","    '---'    "]]
                                      ¢  - call last link (1) as a nilad
                                     j   - join                = (using "..." below to represent mixed-type lists from the result of ¢)
                                                               = [".-----------.","|           |","|           |","'-.       .-'",".-'   -   '-.","|107.6- 42.0|","|106.7- 41.5|","|105.8- 41.0|","|104.9- 40.5|","|104.0- 40.0|","|103.1- 39.5|","|102.2- 39.0|","|101.3- 38.5|","|100.4- 38.0|","| 99.5- 37.5|","| 98.6- 37.0|","| 97.7- 36.5|","| 96.8- 36.0|","| 95.9- 35.5|","| 95.0- 35.0|","'---. - .---'","    | - |    ","    |---|    ","    |   |    ","    '---'    "]
                                       Y - join with newlines  = :
                                                                 .-----------.
                                                                 |           |
                                                                 |           |
                                                                 '-.       .-'
                                                                 .-'   -   '-.
                                                                 |107.6- 42.0|
                                                                 |106.7- 41.5|
                                                                 |105.8- 41.0|
                                                                 |104.9- 40.5|
                                                                 |104.0- 40.0|
                                                                 |103.1- 39.5|
                                                                 |102.2- 39.0|
                                                                 |101.3- 38.5|
                                                                 |100.4- 38.0|
                                                                 | 99.5- 37.5|
                                                                 | 98.6- 37.0|
                                                                 | 97.7- 36.5|
                                                                 | 96.8- 36.0|
                                                                 | 95.9- 35.5|
                                                                 | 95.0- 35.0|
                                                                 '---. - .---'
                                                                     | - |
                                                                     |---|
                                                                     |   |
                                                                     '---'
\$\endgroup\$
12
\$\begingroup\$

Batch, 325 bytes

@echo off
for %%l in ("|           |" "|           |" "'-.       .-'" ".-'   -   '-.")do echo %%~l
set/ac=42,d=5
for /l %%f in (1076,-9,950)do call:c %%f
for %%l in ("'---. - .---'" "    | - |" "    |---|" "    |   |" "    '---'")do echo %%~l
exit/b
:c
set f= %1
set/ac-=!d,d=5-d
echo ^|%f:~-4,-1%.%f:~-1%- %c%.%d%^|
\$\endgroup\$
11
\$\begingroup\$

SOGL, 98 97 bytes

▼⅜¦┌Υ   υl←│Γφγ⅔3wο╚°⁸ofč√&@⁶‘O’⁴∫ |O:9L/*’a6L/+;-l4=?@o}oƧ- o12/*’ ;-o |o"ģ⌠℮Ζ║Kgš‰¶¶ksθ○╤Ƨ%←└⅟ΟS‘

note: the 3 spaces close to the beggining of the program are a tab

Explanation:

...‘O                                                  output the beginning part
     ’⁴∫                                               repeat 15 times, pushing (0-indexed iteration)
         |O                                            output in a new line "|"
           :                                           duplicate the iteration
            9L/                                        push 0.9 (9/10)
               *                                       multiply [0.9 and the iteration]
                ’a6L/+                                 push 107.6 (107+6/10)
                      ;-                               reverse subtract (107.6 - 0.9*iteration)
                        l4=?  }                        if length is 4
                            @o                           output a space
                               o                       output the number
                                Ƨ- o                   output "- "
                                    12/                push 0.5 (1/2)
                                       *               multiply that by iteration
                                        ’              push 42
                                          ;-           reverse subtract (42-0.5*iteration)
                                            o          output that
                                              |o       output "|"
                                                "...‘  push the ending part

To save one byte, I made it push the ending string every time in the loop just so it could get outputted once.

\$\endgroup\$
  • 4
    \$\begingroup\$ Dennis wants you to add a way to try it online so he doesn't have to spend time away from his daughter figuring out where to find a SOGL compiler. \$\endgroup\$ – owlswipe Apr 27 '17 at 2:05
  • 1
    \$\begingroup\$ SOGL never ceases to impress me with its compression \$\endgroup\$ – Cows quack Apr 27 '17 at 8:40
  • 1
    \$\begingroup\$ @owlswipe While SOGL is in heavy development (for example, soon I'm gonna release a version that breaks all programs with functions or compression (I hope it's gonna be the last time)) trying stuff online will not be a priority \$\endgroup\$ – dzaima Apr 27 '17 at 12:57
  • 2
    \$\begingroup\$ @dzaima I didn't realize you personally made SOGL! That is SO cool, very much forgiven for not having a compiler :)) \$\endgroup\$ – owlswipe Apr 27 '17 at 17:52
9
\$\begingroup\$

V, 113 bytes

i|1076- 420|14ñÙ9l5ñÎeé.$hé.
ç|9/á 
o'³-. - .³-'
| - |
|³-|
|³ |
'³-'4>3kHO.±±-.
|±± |Ùo'-.· .-'
.-'³ -³ '-.

Try it online!

Hexdump:

00000000: 697c 3130 3736 2d20 3432 307c 1b31 34f1  i|1076- 420|.14.
00000010: d939 186c 3518 f1ce 65e9 2e24 68e9 2e0a  .9.l5...e..$h...
00000020: e77c 392f e120 0a6f 27b3 2d2e 202d 202e  .|9/. .o'.-. - .
00000030: b32d 270a 7c20 2d20 7c0a 7cb3 2d7c 0a7c  .-'.| - |.|.-|.|
00000040: b320 7c0a 27b3 2d27 1b34 3e33 6b48 4f2e  . |.'.-'.4>3kHO.
00000050: b1b1 2d2e 0a7c b1b1 207c 1bd9 6f27 2d2e  ..-..|.. |..o'-.
00000060: b720 2e2d 270a 2e2d 27b3 202d b320 272d  . .-'..-'. -. '-
00000070: 2e                                       .

More golfing on the way!

\$\endgroup\$
  • 1
    \$\begingroup\$ Dennis doesn't understand how the hell that code works, but appreciate that it works very well in very few bytes. \$\endgroup\$ – owlswipe Apr 27 '17 at 2:04
  • \$\begingroup\$ @owlswipe I doubt it. We're talking about Dennis here; he knows how everything works. ;p \$\endgroup\$ – Kevin Cruijssen Apr 28 '17 at 9:34
  • \$\begingroup\$ @KevinCruijssen Maybe :)). I have no clue how this works though! \$\endgroup\$ – owlswipe Apr 28 '17 at 12:51
  • \$\begingroup\$ @owlswipe Me neither, so I agree it could use an explanation. :) \$\endgroup\$ – Kevin Cruijssen Apr 28 '17 at 12:58
7
\$\begingroup\$

PHP, 187 Bytes

storing 4 spaces in a variable saves 7 Bytes

<?=".-----------.
|",$f="    ","$f   |
|$f$f   |
'-.$f   .-'
.-'   -   '-.
";for($n=85;--$n>69;)printf("|%5.1f-%5.1f|
",$n*.9+32,$n/2);echo"'---. - .---'
$f| - |
$f|---|
$f|   |
$f'---'";

Try it online!

PHP, 188 Bytes

<?$s=".000--.
|1223|1223'-.12.-'
.-'1-1'-.
4";for($n=85;--$n>69;)$t.=sprintf("|%5.1f-%5.1f|
",$n*.9+32,$n/2);$s.="'0. - .0'
2| - 32|032|132'0'";echo strtr($s,["---","   ","    ","|
",$t]);

Try it online!

PHP, 220 Bytes

<?=gzinflate(base64_decode("XZBJCkUhDAT3niI7VzbOw908/O/EwIMviCnLQBukbyFc+db9o5jgNVIM3KwSd9S+khdmkl6Rr9LEIhUMo4Ft9FzHIWV3HdnouYaSpB13FdXouYJG2u4yupE6OewgLXNytmYhPbc0S5vupmYhPTc0SxvuhmYhZf0t58H/gWcMNgHSfRXvvLLJiE2B734="));

Try it online!

PHP, 247 Bytes

<?=bzdecompress(base64_decode("QlpoNDFBWSZTWREU1+kAAEnYgEiQQIN/4AAEMAC6bDTRA1NBtqglJ7VIA0AJNSEAAXhknxmxdEkbQhoFWMYrEL1cASWoMYgwHEpJJJKZmZ638CwPCeQHBCLKs3qj1vvz37lF4trWtWviLC4wJoHJywEMA8GmAh2WwUSEom/JeNAioiokhJa9V5bL02pVVVXw+EiwPxdyRThQkBEU1+k="));

Try it online!

\$\endgroup\$
5
\$\begingroup\$

Python 2, 163 bytes

i=89
for x in("------.x|x|x.-'x-   '-."+"x"*16+"- .---'x- |x--|x  |x--'").split('x'):y='%%-77ss'[i>80::2]%x;print['|%5s- %s|'%(32+.9*i,i/2.),y[:0:-1]+y][x>''];i-=1

Try it online!

\$\endgroup\$
  • \$\begingroup\$ I’m late to this party, but y='%*s'%(i/80*14-7,x) saves a byte. \$\endgroup\$ – Lynn Aug 12 '17 at 17:56
4
\$\begingroup\$

///, 261 bytes

/`/\/\///i/|
|`~/---`_/   `+/- `f/.5`z/.0`(/i10`)/i 9`!/|
    |/
.--~~~.
|  ___i  ___|
'-. __.-'
.-'_-_'-.
|107.6+42z(6.7+41f(5.8+41z(4.9+40f(4.0+40z(3.1+39f(2.2+39z(1.3+38f(0.4+38z)9f+37f)8.6+37z)7.7+36f)6.8+36z)5.9+35f)5.0+35z|
'~. - .~'
    | - !~!_|
    '~'

Try it online!

Works by using common occurrences like --- as replacements. Nothing fancy.

\$\endgroup\$
4
\$\begingroup\$

APL (Dyalog), 144 143 bytes

m←⊢,1↓⌽
1⌽'.||',⍣2⊢11/⍪3↑d←'-'
m 7↑a←∪∊z←⊂'''---. -'
m(6↑⌽a),d
⊃{'|',⍵,'-',⍺,'|'}/(5 1⍕⍪)¨35 95+↓.5 .9∘.×⌽⍳15
↑m¨z,¯7↑¨'| -' '|--' '|  ' '''--'

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Mathematica 247 Bytes

Hmmm... same as PHP

Uncompress@"1:eJxtkLsNAyEQRM+d4OgiRssf2rBTR27ADdCG+/WAODYxEkL7eKDR3N+fx/N7Ow5YXXiJ893o6n/BabFG2HMAHhws97n+cFKQrYke0hfIKAQO6QIJdYJtRDQCUSNCJthGgLMmNDU8/ATbcAgEVQ1BnGAZpvE1QbkM0+pISrCNMpKGrEYeSQm2kUbSkNRIIymBrILYJfsY3c6CZnUEfQ+80eEq1swG+eYH1XhZzA=="
\$\endgroup\$
3
\$\begingroup\$

JavaScript (ES6), 198 bytes

Number formatting is a bit costly in JS and I seem to be stuck at this byte count. You win this time, PHP! ;-)

let f =

_=>`.222--.
|56|
|56|
'-.7.-'
.-'3-3'-.
000000000111111'2. - .2'
4| - |
4|2|
4|3|
4'2'`.replace(/\d/g,n=>['|'+(s=F(32+.9*i)+`- ${F(i--/2)}|
`),'| '+s,'---'][n]||' '.repeat(n),i=94,F=v=>v.toFixed(1))

console.log(f())

\$\endgroup\$
  • 1
    \$\begingroup\$ I hope that you are not angry about that I could save 8 Bytes more. Thank You for the reminder to try a second approach with strtr \$\endgroup\$ – Jörg Hülsermann Apr 27 '17 at 14:18
  • 1
    \$\begingroup\$ @JörgHülsermann No worries! :) Well done! \$\endgroup\$ – Arnauld Apr 27 '17 at 14:23
3
\$\begingroup\$

Japt, 106 bytes

[".{6î-}
|
'-.
.-'   -"y y 9"'
-
-
-
.|||'
  - -
--- -"y]·mê0R d9FÆ"|{S+(#k6-9*X)t4n)i.J}- {½*Xn84)x1}|"÷

Test it online!

Many thanks to @obarakon who got the code working in the first place, and did quite a bit of the golfing.

Explanation

First we have the data:

[                                     // Create an array of:
  ".{6î-}\n|\n'-.\n.-'   -"           //   This string ({6î-} inserts 6 hyphens),
  y y                                 //   transposed twice to pad it with spaces;
  9                                   //   the number 9;
  "'\n-\n-\n-\n.|||'\n  - -\n--- -"   //   and this string,
  y                                   //   transposed once.
]·                                    // Join the array with newlines.

This gives us

.------
|      
'-.    
.-'   -
9
'---. -
    | -
    |--
    |  
    '--

That is, the left half of the thermometer, with the main rectangle replaced with a 9. Note that every line is padded with spaces except the one containing the 9.

m  R   // Map each line with the function
 ê     //   ê, or "bounce"; mirrors the string about its last character ("abc" -> "abcba").
       // (The 0 is just filler because `m` expects the `R` to be the third parameter)

The net effect is that it mirrors the left half of the thermometer to the right:

.-----------.
|           |
'-.       .-'
.-'   -   '-.
9
'---. - .---'
    | - |    
    |---|    
    |   |    
    '---'    

Now that we have the ASCII-art part, all we have to do is put in the main rectangle:

d9FÆ  "|{S+(#k 6-9*X)t4n)i.J}- {½ *Xn84)x1}|"Ã ·
d9FoX{"|{S+(1076-9*X)t4n)i.J}- {.5*Xn84)x1}|"} qR

  FoX{  ...  }        // Create the range [0...15), and map each item X to
"|{ ... }- { ... }"   //   this string, with the two blanks filled in with...

S+(1076-9*X)t4n)i.J
   1076-9*X           //   Calculate 1076 - 9*X. This gives us °F * 10.
S+(        )t4n)      //   Prepend a space and take only the last 4 chars.
                      //   This pads the entries under 100°F to the correct length.
                i.J   //   Insert a decimal point before the last char.
                      //   This turns e.g. "1076" to "107.6".

.5*Xn84)x1
   Xn84               //   Take 84 - X.
.5*    )              //   Multiply it by 0.5. This gives us °C.
        x1            //   Convert to a string with exactly 1 decimal point.

                qR    // Join the resulting array with newlines.
d9                    // In the thermometer art, replace "9" with the resulting string.

And that concludes our ASCII-art generating session. Tune in next week to see more kinda-short ASCII-art programs written in Japt!

\$\endgroup\$
2
\$\begingroup\$

Charcoal, 62 bytes

←⁶↓.↓²'-.¶.-'¶↓¹⁵'³↓.↓³'²M²↖¹↑×¹⁹-‖OM⁵¦¹⁶←E¹⁵⮌⁺⁺⁺⁹⁵×·⁹ι- ⁺³⁵⊘ι

Try it online! Link is to verbose version of code. Explanation:

←⁶↓.↓²'-.¶.-'¶↓¹⁵'³↓.↓³'²M²↖¹↑×¹⁹-

Print the left half of the thermometer.

‖O

Reflect it to complete the body.

M⁵¦¹⁶←E¹⁵⮌⁺⁺⁺⁹⁵×·⁹ι- ⁺³⁵⊘ι

Compute the scales and print them reversed and up-side down, which right-justifies them. At time of writing, Charcoal's concatenation operator converts floats to strings using Python's built-in str which appends .0 for floats that represent integers, otherwise I would have to resort to formatting, as its Cast operator specifically avoids that behaviour.

\$\endgroup\$
1
\$\begingroup\$

vim, 222 keystrokes

:.!seq 42 -0.5 35
:%!awk '{printf("|\%5.1f- \%.1f|\n",1.8*$1+32,$1)}'
Go'===. - .==='<ESC>yy
:s/=/-/g
p
:.!tr "'.=" ' | '
:s/ *$/
yyP
:s/-/ /
ddpPlR---<ESC>yyGp
:s/|/'/g
ggO..<ESC>11i-<ESC>yyP
:.!tr .- '| '
yypo'-.<ESC>7a <ESC>a.-'<ENTER>.-'   -   '-.<ESC>
\$\endgroup\$
1
\$\begingroup\$

C, 234 bytes

main(i){float f=42;puts(".-----------.");for(;i--;)printf("|%*s|\n",11,"");puts("'-.       .-'\n.-'   -   '-.");for(;f>34.5;f-=.5)printf("|%5.1f- %.1f|\n",32+f*1.8,f);puts("'---. - .---'\n    | - |\n    |---|\n    |   |\n    '---'");}

Try it online

Output:

.-----------.
|           |
|           |
'-.       .-'
.-'   -   '-.
|107.6- 42.0|
|106.7- 41.5|
|105.8- 41.0|
|104.9- 40.5|
|104.0- 40.0|
|103.1- 39.5|
|102.2- 39.0|
|101.3- 38.5|
|100.4- 38.0|
| 99.5- 37.5|
| 98.6- 37.0|
| 97.7- 36.5|
| 96.8- 36.0|
| 95.9- 35.5|
| 95.0- 35.0|
'---. - .---'
    | - |
    |---|
    |   |
    '---'
\$\endgroup\$
0
\$\begingroup\$

C, 460 265 bytes

#define P(x) puts(x);
#define Z "|           |"
T(){float i=7,j=12.6;P(".-----------.")P(Z)P(Z)P("'-.       .-'")P(".-'   -   '-.")while(i>=0)printf("|%5.1f- %.1f|\n",95+j,35+i),i-=.5,j-=.9;P("'---. - .---'")P("    | - |")P("    |---|")P("    |   |")P("    '---'")}

Output Live

.-----------.
|           |
|           |
'-.       .-'
.-'   -   '-.
|107.6- 42.0|
|106.7- 41.5|
|105.8- 41.0|
|104.9- 40.5|
|104.0- 40.0|
|103.1- 39.5|
|102.2- 39.0|
|101.3- 38.5|
|100.4- 38.0|
| 99.5- 37.5|
| 98.6- 37.0|
| 97.7- 36.5|
| 96.8- 36.0|
| 95.9- 35.5|
| 95.0- 35.0|
'---. - .---'
    | - |
    |---|
    |   |
    '---'
\$\endgroup\$
  • 1
    \$\begingroup\$ This doesn't look very golfed. Can't you e.g. combine the two identical lines? Also, you have a leading space on all lines \$\endgroup\$ – Adám Apr 27 '17 at 13:37
  • \$\begingroup\$ @Adám golfed now. \$\endgroup\$ – Khaled.K Apr 27 '17 at 13:46
  • 1
    \$\begingroup\$ Maybe you can define the four spaces and reuse them? For-loop with math for all the numbers? \$\endgroup\$ – Adám Apr 27 '17 at 13:51
  • \$\begingroup\$ @Adám thx, golfed further now. \$\endgroup\$ – Khaled.K Apr 27 '17 at 15:20
  • \$\begingroup\$ You're missing the lowest temperatures: 95.0- 35.0 \$\endgroup\$ – Adám Apr 27 '17 at 16:26
0
\$\begingroup\$

Go, 238 bytes

Wow, that string is really resistant to golfing...

package main
import."fmt"
func main(){p:=Printf
s,i:=`|           |
`,42.
p(`.-----------.
`+s+s+`'-.       .-'
.-'   -   '-.
`)
for;i>=35;i-=.5{
p(`|%5.1f- %.1f|
`,i*9/5+32,i)}
p(`'---. - .---'
    | - |
    |---|
    |   |
    '---'`)}

Try live here: https://play.golang.org/p/tPKYxII7NC

\$\endgroup\$
0
\$\begingroup\$

C, 222 bytes

f(){puts(".-----------.\n|           |\n|           |\n'-.       .-'\n.-'   -   '-.");for(float n=108.5,m=42.5;m>35;printf("|%5.1f- %.1f|\n",n-=.9,m-=.5));puts("'---. - .---'\n    | - |\n    |---|\n    |   |\n    '---'");}

Despite attempting to shorten the string, hardcoding it in a plain format is the best option. I doubt that any (significant) improvement is possible in C.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.