• Task:
    With the minimum amount of bytes, determine today's Zodiac sign using the programming language of your choice.
  • Rules:
    This is code golf, the answer with the fewest characters wins. The initialization of getting the current date into a variable (e.g. var now = new Date();) does not add to the count. Leap years must be handled correctly.
  • Limitations:
    You cannot use any other library functions for handling dates, nor predefined lists. In particular, participants would have to calculate the ordinal day of the year themselves if needed.
  • Input:
    The current date in the proleptic Gregorian calendar with numeric year, month (1–12) and day of the month (1–28…31).
  • Output:
    A single Unicode symbol indicating the current one of the twelve Zodiac signs from Western astrology, as used in horoscopes and listed below:
  1. ♈︎ Aries: March 21 – April 19
  2. ♉︎ Taurus: April 20 – May 20
  3. ♊︎ Gemini: May 21 – June 21
  4. ♋︎ Cancer: June 22 – July 22
  5. ♌︎ Leo: July 23 – August 22
  6. ♍︎ Virgo: August 23 – September 22
  7. ♎︎ Libra: September 23 – October 22
  8. ♏︎ Scorpio: October 23 – November 22
  9. ♐︎ Sagittarius: November 23 – December 21
  10. ♑︎ Capricorn: December 22 – January 19
  11. ♒︎ Aquarius: January 20 – February 18
  12. ♓︎ Pisces: February 19 – March 20

The actual dates might differ by one day depending on the year, but for this task the above date ranges are considered accurate for every year.


The sign for today, 28 February 2022, is Pisces, so the correct output would be ♓︎.

Related challenges

  • 7
    \$\begingroup\$ The rule about getting the current date into a variable is an assumption about language features, which should be avoided. You should probably just stick to standard I/O rules. Also, it's currently a bit unclear what the input exactly is. Can we just take a month and a day? (Translating that into a zodiac sign is the core of the challenge anyway.) \$\endgroup\$
    – Arnauld
    Commented Feb 28, 2022 at 14:35
  • \$\begingroup\$ To me, it sounds like the input to your code is the day, month, and year, all one-indexed; any code that gets the current date using language facilities does so only to format that date as input to the code. I do agree that it's a bit poorly explained in that regard. \$\endgroup\$
    – nununoisy
    Commented Feb 28, 2022 at 14:49
  • 1
    \$\begingroup\$ I did not want to give languages that have a global now object or something like that an advantage, so if your language does not have something like that, you can still assume that there is a variable that has this information. You are right that this boils down to: you have a month number and a day number. \$\endgroup\$
    – Crissov
    Commented Feb 28, 2022 at 14:49
  • 5
    \$\begingroup\$ Possible duplicate \$\endgroup\$ Commented Feb 28, 2022 at 17:27
  • \$\begingroup\$ Thanks @DigitalTrauma I assume there would be a challenge like this but did not find the one you are linking to. However, with symbol output I expect slightly different results. \$\endgroup\$
    – Crissov
    Commented Feb 28, 2022 at 18:13

4 Answers 4


JavaScript (Node.js),  64  62 bytes

Expects (month)(day).

This version builds the UTF-8 encoding of the code point (from 0xE2 0x99 0x88 for Aries to 0xE2 0x99 0x93 for Pisces).


Try it online!

ES6, 63 bytes

Using the more straightforward String.fromCharCode() with a direct code point is one byte longer.


Try it online!

  • \$\begingroup\$ what does Buffer do? \$\endgroup\$
    – DialFrost
    Commented Mar 1, 2022 at 1:19
  • \$\begingroup\$ Buffers are related to strings. \$\endgroup\$
    – Someone
    Commented Mar 1, 2022 at 1:24
  • 2
    \$\begingroup\$ @DialFrost Buffer is a Node thing. And what really should be used here is Buffer.from(array), followed by .toString('utf8'). \$\endgroup\$
    – Arnauld
    Commented Mar 1, 2022 at 1:25
  • \$\begingroup\$ I like how you used standard programming language and didn’t need many more bytes than others with golfing languages. \$\endgroup\$
    – Crissov
    Commented Mar 17, 2022 at 11:58

Jelly, 27 bytes


A dyadic Link accepting an integer, month, on the left and an integer, day, on the right that yields a character.

Try it online! Or see a whole year.


“£f{ẋ’b5⁸ị+19>_@⁸_3%12+⁽#1Ọ - Link: M; D
“£f{ẋ’                      - 53343748
      b5                    - to base five -> [1, 0, 2, 1, 2, 3, 4, 4, 4, 4, 4, 3]
        ⁸ị                  - get the item at 1-indexed index M
          +19               - add nineteen to it
             >              - is that greater than D? -> 1 or 0
              _@⁸           - subtract from M -> M-1 or M
                 _3         - subtract three (offset since characters start at March)
                   %12      - modulo twelve
                       ⁽#1  - 9800
                      +     - add
                          Ọ - cast to character

Retina 0.8.2, 112 bytes


Try it online! Link includes test cases. Takes input in the format mm-dd. Does not output a Unicode variation selector, but the output looks fine in TIO to me. Explanation:


Change October to December to k to m, which will become Scorpio to Capricorn.


Change January to September to b to j, which will become Aquarius to Libra.


Increment the encoded sign if the day is past the cutoff date for the next sign.


Delete everything except the encoded sign.


Decode to a Unicode Zodiac sign.


Charcoal, 31 bytes


Try it online! Link is to verbose version of code. Takes separate month and day as inputs. Explanation:

Nθ                           First input as a number
              N              Second input as a number
             ›               Is greater than
                    ”...”    Compressed string `310212344444`
                   §         Cyclically indexed by
                         θ   Input month
                  I          Cast to integer
               ⁺             Plus
                ¹⁸           Literal integer `18`
           ⁺                 Plus
            θ                Input month
         ⁺                   Plus
          ⁸                  Literal integer `8`
        ﹪                    Modulo
                          ¹² Literal integer `12`
   ⁺                         Plus
    ⁹⁸⁰⁰                     Literal integer `9800`
  ℅                          Convert to Unicode
                             Implicitly print

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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