What season is it?

-7

Task

When running the program must show the season according to the host computer's current time.

Rules

  • The output must be either: Spring, Winter, Summer or Autumn.

  • The capitalization does not matter.

  • The output must not contain anything else the the season names stated above.

  • A season is 3 months and january is in this case the start of spring. (Northern hemisphere)

Testcase

(program ran in January)

Output:

Spring

(program ran in April)

Output:

Summer

Scoring

This is . Shortest answer in bytes wins.

Luc H

Posted 2017-05-20T16:55:32.190

Reputation: 461

Question was closed 2017-05-20T18:10:05.593

Can we return one of 0, 1, 2, 3 instead of Spring, Winter, Summer, Autumn? – Stephen – 2017-05-20T16:59:31.383

9What ranges of dates are in each season? – Rohan Jhunjhunwala – 2017-05-20T16:59:40.970

And in mine, spring starts from march – Mr. Xcoder – 2017-05-20T17:45:30.673

What if I live in the Southern Hemisphere? – Ian Miller – 2017-05-21T15:59:29.107

@IanMiller do you have other seasons there? for this challenge you need to output the season as in january is the start of spring december is the end of winter etc – Luc H – 2017-05-21T17:37:13.463

And can someone tell my what is unclear as i would like to clear up any confusing things. The current anwsers all followed the challenge – Luc H – 2017-05-21T17:38:00.613

@Ayoungcoder can you provide specific date ranges for "3 months"? Should we just use the solstices/equinoxes? And january is definitely winter... – Rɪᴋᴇʀ – 2017-05-21T18:43:44.663

Of course the Southern Hemisphere has different seasons. For example January would be the middle of summer. I therefore thought that January would be the middle of winter in the Northern Hemisphere. – Ian Miller – 2017-05-22T14:30:43.583

Answers

2

05AB1E, 25 16 bytes

“Ž¹Ž€È±–„“#žf3÷è

Explanation:

“Ž¹Ž€È±–„“        Push the string 'spring summer autumn winter'
          #       Split on spaces
           žf     Push month
             3÷   Integer divided by 3
               è  Index

Try it online!

Okx

Posted 2017-05-20T16:55:32.190

Reputation: 15 025

6

Jelly, 40 bytes

“¡ɗNʂ:ḲO¶Z{ṅ{Ḳ®⁵⁹¢»ŒV’:3ị“ȷ14ċ⁵¶<b_þṭ»Ḳ¤

Jelly has no native date functionality, yet this program prints Spring in January, February and March; Summer in April, May and June; Autumn in July, August, and September; and Winter in October, November and December.

Try it online!

How?

“¡ɗNʂ:ḲO¶Z{ṅ{Ḳ®⁵⁹¢»ŒV’:3ị“ȷ14ċ⁵¶<b_þṭ»Ḳ¤ - Main link: no arguments
“¡ɗNʂ:ḲO¶Z{ṅ{Ḳ®⁵⁹¢»                      - compressed string: " time.gmtime().tm_mon"
                   ŒV                    - evaluate Python code - gets the month, January=1 ... December=12 (the time module has been imported in the interpreter for the time formatting atom ŒT)
                     ’                   - decrement
                     :3                  - integer divide by three
                                       ¤ - nilad followed by link(s) as a nilad:
                         “ȷ14ċ⁵¶<b_þṭ»   - compressed string "Summer Autumn Winter Spring"
                                      Ḳ  - split on spaces
                        ị                - index into (1-based)
                                         - implicit print

Jonathan Allan

Posted 2017-05-20T16:55:32.190

Reputation: 67 804

That is stupidly clever. Take a +1. – caird coinheringaahing – 2017-05-22T18:32:22.570

1

Japt, 32 30 27 bytes

`spÎAdä>H©umØC`qd gKg z3

Try it online


Explanation

A compressed string of lowercase, separated season names delimited with d is decompressed by enclosing it in backticks. qd splits the string into an array on ds. The g method gets the element at the index of the current month (Kg) floor divided by 3 (z3).

Shaggy

Posted 2017-05-20T16:55:32.190

Reputation: 24 623