ASCII Art of the Day #4 - Zodiac Signs

12

1

We all love horoscopes, don't we? But I have a serious problem in this Horoscope App installed on my Smart Phone that it only displays the icon of the Zodiac Sign for each day's horoscope. Now, I do remember my horoscope, but its hard to remember others' whose horoscope I am interested in.

Challenge

So here is your challenge for an another addition to the ASCII Art of the Day series. Given a date and month input, output the corresponding Zodiac sign in ASCII format as shown below. Each Zodiac Sign is followed after the name and date range (DD MM format) for the zodiac sign.

Aries - 21 03 - 20 04
 .-.   .-.
(_  \ /  _)
     |
     |
Taurus - 21 04 - 20 05
 .     .
 '.___.'
 .'   '.
:       :
:       :
 '.___.'
Gemini - 21 05 - 20 06
._____.
  | |
  | |
 _|_|_
'     '
Cancer - 21 06 - 20 07
   .--.
  /   _'.
 (_) ( )
'.    /
  '--'
Leo - 21 07 - 20 08
  .--.
 (    )
(_)  /
    (_.
Virgo - 21 08 - 20 09
 _
' ':--.--.
   |  |  |_
   |  |  | )
   |  |  |/
        (J
Libra - 21 09 - 20 10
     __
___.'  '.___
____________
Scorpio - 21 10 - 20 11
 _
' ':--.--.
   |  |  |
   |  |  |
   |  |  |  ...
         '---':
Sagittarius - 21 11 - 20 12
      ...
      .':
    .'
'..'
.''.
Capricorn - 21 12 - 20 01
        _
\      /_)
 \    /'.
  \  /   :
   \/ __.'
Aquarius - 21 01 - 20 02
.-"-._.-"-._.-
.-"-._.-"-._.-
Pisces - 21 02 - 20 03
'-.    .-'
   :  :
 --:--:--
   :  :
.-'    '-.

Input

  • You would be provided two integers corresponding to the date of month and month of year (in that order) of the birthday.
  • The date and month will be 1 indexed like in normal calendars.
  • You can take input form STDIN/ARGV/function arguments or the closest equivalent

Output

  • Based on what date range the input date falls in, output to STDOUT, the corresponding Zodiac Sign.
  • You can have upto 4 trailing spaces in each line but no leading spaces that are not part of the output.
  • You can either write a full program or a named function.

This is so the shortest code in bytes wins!


Leaderboard

The first post of the series generates a leaderboard.

To make sure that your answers show up, please start every answer with a headline, using the following Markdown template:

# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

# Ruby, <s>104</s> <s>101</s> 96 bytes

Optimizer

Posted 2015-06-01T13:28:55.327

Reputation: 25 836

1

Related: http://codegolf.stackexchange.com/q/35036/29750

– NinjaBearMonkey – 2015-06-01T14:41:10.030

@NinjaBearMonkey I know about it, but that one is more detailed and emphasized on date parsing – Optimizer – 2015-06-01T15:20:05.967

I know, I would definitely not consider it a duplicate, but I just thought I would mention it. – NinjaBearMonkey – 2015-06-01T15:23:16.987

Are the trailing spaces on the last lines of Taurus and Pisces intentional? – Siguza – 2015-06-01T16:43:24.783

@Siguza you can anyways have upto 4 trailing spaces. So it does not matter :) – Optimizer – 2015-06-01T16:46:07.103

That means I can have less trailing spaces than the example as well, I assume then. – Siguza – 2015-06-01T17:09:32.870

@Siguza Yes, I updated anyways. – Optimizer – 2015-06-01T17:31:56.243

Are the simplified date ranges intentional? – Dennis – 2015-06-01T18:35:27.520

@Dennis Yes. I wanted this to be more of ASCII art than Date parsing and partitioning. – Optimizer – 2015-06-01T19:45:17.717

Answers

7

CJam, 296 284 272 265 264 bytes

"03½åÙªWË#å¥ÜZ2ò'ýðDc}¦Ð£RÞ5ä<Üå§ÖÞYÏuäOe¤¶è2²|ZëßB«ô¬cm"257b2bSf*Qa/"®=&ðS¢Òpût£Ð`ç«^º,[öÄ©3¸YÝæ[%$>\D£(´õÓÆeUØRHáÄ¡ããîùK½ÊÆÇ:UBÍm¥·fèäBÓEwWOkQq×tÌVfè£g8·¨    q©ñäp-ÁgUÚ´Éõ'>r    Ê#"256bDb"
.\"'()-/:\_|J"f=.+sSN+/l~\K>+=

Try it online in the CJam interpreter.

Idea

We start by joining all twelve signs using the string <SP><LF> as separator. We opt for the zodiac signs not to contain trailing spaces, so this allows to separate them easily.

The joined string is 542 bytes long. 236 of these bytes are spaces, which is almost half of them. We build an array that contains a 1 for every space and a 0 for every non-space. This way, encoding a space will only cost 1 bit.

Removing all spaces from the joined string, we are left with the characters <LF>."'()-/:J\_|. Assigning each of them a value (e.g., the index in this string) between 0 and 12

Finally, we decode the above base 2 and base 13 arrays as byte arrays.

In the final program, for a given input DD MM, we compute (int(MM) + (int(DD) > 20)) % 12, reverse the above process to obtain the array of all zodiac signs and select the proper one.

Code

"03½åÙªWË#å¥ÜZ2ò'ýðDc}¦Ð£RÞ5ä<Üå§ÖÞYÏuäOe¤¶è2²|ZëßB«ô¬cm"

        e# Push the encoded space positions.

257b2b  e# Convert from base 257 to base 2.
Sf*     e# Replace 1's with spaces and 0's with empty strings.
Qa/     e# Split at empty strings.

"®=&ðS¢Òpût£Ð`ç«^º,[öÄ©3¸YÝæ[%$>\D£(´õÓÆeUØRHáÄ¡ããîùK½ÊÆÇ:UBÍm¥·fèäBÓEwWOkQq×tÌVfè£g8·¨ q©ñäp-ÁgUÚ´Éõ'>r    Ê#"

        e# Push the encoded non-space characters.

256bDb  e# Convert from base 256 to base 13.

"
.\"'()-/:\_|J"f=

        e# Replace each digit in base 13 by the corresponding character.

.+s     e# Interleave both arrays to create a string.
SN+/    e# Split at trailing spaces.
l~      e# Evaluate the input from STDIN.
\K>+    e# Add 1 to the month if the day is larger than 20.
=       e# Retrieve the corresponding element from the array.

Dennis

Posted 2015-06-01T13:28:55.327

Reputation: 196 637

УRÞ? DERP. . . – unclemeat – 2015-06-02T22:53:28.503

Longest golf Lang solution I've ever seen. – Pavel – 2017-01-01T10:23:51.883

3

CJam, 324 bytes

"%[hÿìs5!zaÆT=ªñ=Û]ÌUMàûÓ»¦f¼³ëµ1þÈUÑyéC4¬u1T9KÍü!+Úøöà&J~âZ®uRtkRÿ+*ÐFeÜPý¤SÙËU7óÎ?LXÝ2D@0¶ÆÀ¡kÚça­çªñܧ#iµ3L®ó&Ë'iºyè½?JS÷SjS`ösÓò»zjRoaÃIYrµ&M>ÍKaaúcg®Ð\p¨²:LqÜݶo¯ÆkµúÒ4Ezú©æ¼xP»¸¯gd^ßg±>ï ÃºDÎŧ@3Bßt\<GÒcû)ËûwíUÑdØoiTv>¤&ý°mÊ13ÛUÿØjª¬Ì±(¦¿çÍX4tõãÜÑ*ÃmÜ9ãSÁ3IþÜìÙ,"{_'~>33*32+-}%191bEb428Et"
 \"'()-./:\_a|J"f='a/q~\K>+=

My first attempt. Try it online

aditsu quit because SE is EVIL

Posted 2015-06-01T13:28:55.327

Reputation: 22 326

2

Python 2, 961 698 692 687 Bytes

Definitely still going to golf further, just wanted to put an idea down. Now using a dictionary.

a,b=raw_input().split()
b=int(b)
c='.-"-._.-"-._.-'
print{0:c+'\n'+c,1:"'-.    .-'\n   :  :\n --:--:--\n   :  :\n.-'    '-.",2:" .-.   .-.\n(_  \ /  _)\n     |\n     |",3:" .     .\n '.___.'\n .'   '.\n:       :\n:       :\n '.___.'",4:"._____.\n  | |\n  | |\n _|_|_\n'     '",5:"   .--.\n  /   _'.\n (_) ( )\n'.    /\n  '--'",6:"  .--.\n (    )\n(_)  /\n    (_.",7:" _\n' ':--.--.\n   |  |  |_\n   |  |  | )\n   |  |  |/\n        (J",8:"     __\n___.'  '.___\n"+'_'*12,9:" _\n' ':--.--.\n   |  |  |\n   |  |  |\n   |  |  |  ...\n         '---':",10:"      ...\n      .':\n    .'\n'..'\n.''.",11:"        _\n\      /_)\n \    /'.\n  \  /   :\n   \/ __.'"}[[[b-2,11][b<2],b-1][int(a)>20]]

Old method, using interleaving.

d,m=raw_input().split()
m=int(m)
print'.\'  .       --.._  _ _  ".- _ .\n \n  - . _.-\' \'  .   _--     _   _-.\'_\'  .   ..\n:_:. -...\n\n -\n-. "--\n  (-_-._-\'.    ._.\n\n.\n\n\'|/ -_- \\_ (.   -.-  . __|  .\'.  -  _\n )\n \n  \n: _ _\n     . \\. \'( \'   -  \'|._ . . ":/\n \n)|_|\'/-\n  |   _ :_.  .\n(  _ \n)_-_\' _/|\n| \n.-) _)\n _   -:\n |   _  \\"-  _( |_|  -- \'|  __\n. .: ._) \n_ \' _- \n\n\n( _ \n .- :\'\'_ _ \'/-\n|  .. _|.\'  \n    |_ ..        _ \'\n        _|\n  :     |_ .     \'/    \'\\     \n   |\'  :|:   | \n.  \n \n       / . : \' )     -   - \n     \'   -   |       \'     :           \n       | |               \'           - :   | | \\ . \n       /               \'   | . _   .   / . _   _   \n . .   _     \n \'   _           .           \'                                                               (           J             \'           -           -           -           \'           :  '[[m-2,m-1][int(d)>21]::12].rstrip()

Kade

Posted 2015-06-01T13:28:55.327

Reputation: 7 463

2

Python 2, 565 568 553 bytes

def z(d,m):b="\n "+"  |"*3;c=" _\n' ':--.--.";a="  ...\n      ";print["\      /_)\n \    /'.\n  \  /   :\n   \/ __.'",'.-"-._.-"-._.-\n'*2,"'-.    .-'\n   :  :\n --:--:--\n   :  :\n.-'    '-.",' .-.   .-.\n(_  \ /  _)'+'\n     |'*2," .     .\n '.___.'\n .'   '.\n:       :\n:       :\n '.___.'","._____.\n  | |\n  | |\n _|_|_\n'     '","   .--.\n  /   _'.\n (_) ( )\n'.    /\n  '--'",'  .--.\n (    )\n(_)  /\n    (_.',c+b+"_"+b+" )"+b+"/\n        (J","     __\n___.'  '.___\n"+"_"*12,c+b*3+a+"   '---':","    "+a+".':\n    .'\n'..'\n.''."][m%12-(d<21)]

So I was a bit lazy and decided not to golf this AAotD. Instead, I decided to let python golf itself.

The above solution was created using the code below:

full_string = """
\      /_)
 \    /'.
  \  /   :
   \/ __.'
*
.-"-._.-"-._.-
.-"-._.-"-._.-
*
...               # The others in this list as well
*
      ...
      .':
    .'
'..'
.''.
"""

# Golf the input string
string_list = full_string.split('*')
# Remove begin and end \n
string_list = [s[1:-1] for s in string_list]
# Remove unnescessary repr characters
golf = repr(string_list).replace(r'\\ ', r'\ ').replace(r'\\/', r'\/').replace(', ', ',')
# Special case for the Aquarius as it's a full duplicate
middle = golf.find('\\n', 50)
end = golf.find(',', middle)
golf = golf[0:middle+2] + "'*2" + golf[end:]
# Special case for the 12 underscores
golf = golf.replace('____________"', '"+"_"*12')
# Replace the three bars and their whitespace
golf = golf.replace('\\n   |  |  |', '"+b+"')
# Replace the bar-cover
cover = '" _\\n\' \':--.--."'
golf = golf.replace(cover, 'c')
# Replaces aries' foot
golf = golf.replace("\\n     |\\n     |'", "'+'\\n     |'*2")
# Replace dots
golf = golf.replace('  ...\\n      ', '"+a+"')
# Remove empty strings and optimize b's
golf = golf.replace('""+', '').replace('b+b+b', 'b*3')

# Surround the lookup table with the function that that prints the correct zodiac sign for the day/month
golf = 'def z(d,m):a="  ...\\n      ";b="\\n "+"  |"*3;c=" _\\n\' \':--.--.";print' + golf + '[m%12-(d<21)]'

Matty

Posted 2015-06-01T13:28:55.327

Reputation: 471

This doesn't produce the right output at all.. All of them need to be shifted, and if you go over 20,12 then the list index goes out of range. z(21,1) should produce Aquarius, yet it produces Picses, etc.. – Kade – 2015-06-02T14:00:01.290

@Vioz- Wow, I'm getting sloppy. Thanks, it works properly now. – Matty – 2015-06-02T15:20:57.813

1

Perl, 414

Not a lot to do here, just applied dictionary compression:

#!perl -p
/ /;$i=$'%12-($`<21);
$_="cc_
\\ct_s \\c/'ga\\thlh\\/ __ijkee
keej'-.ck'n q:q:qnk'c'-gA k.hkg(_a\\ /a_sm|
m|j .mg oi
 ih'g:chl:chl oij.d__grr _|_|_
'm'jhk-gth_'g (_) ( s'.c/
a'q'jak-g (cs(_)t
c(_.f_b )b/
cc(Jjm__
diao
ddddfbbpm'q-':jcpailci
'.i
i'g";
1while s![a-t]!(split z,"  z
a |a|a|zaaz___z\"-._.-z
A _
' ':--.--.bz.
za z.'z
Az.-z:
zc z
h:alz'.dza..gcz--za| |
z)
za/")[(ord$&)%97]!e;$_=(split A)[$i]

Test me.

nutki

Posted 2015-06-01T13:28:55.327

Reputation: 3 634