Employers love to see their employees working hard, while the employees would love to work less, especially those with a monthly rather than hourly payment.

The laziest of employees are thinking about the world where every month starts with the same weekday and it makes them wonder if they would work more or less.

The greediest of employers are thinking about the world where every month starts with the same weekday and it makes them wonder if their employees would work more or less.

Your task (as a lazy employee or greedy employer, you choose) is to write the shortest program or function that given weekday every month must start outputs the number of working and weekend days.


  • Weekday identificator. This can be a 0- or 1-based index, case-insensitive shortname (Mo/Mon, Tu/Tue etc) or case-insensitive full name (Monday, tuesday etc) as long as you specify the format.


  • One of the following output formats allowed:
    1. A string of single space/comma/semicolon separated values.
    2. A list of values.
    3. A multi-line string of values with a trailing line break allowed.
  • The output format must be consistent.
  • 2 values must present in the output: number of working days in base 10 and number of weekends in base 10.


  • Assume the year is 365 days.
  • Workdays are Monday, Tuesday, Wednesday, Thursday and Friday.
  • Week starts with Monday.
  • No national weekends are accounted.
  • This is so all usual golfing rules apply, and the shortest code (in bytes) wins.


 Input  | Output
 Monday | 269 96
    Tue | 269,96
      3 | 269 96   // 1-based index
      3 | 262, 103 // 0-based index
     fr | 251;114
      5 | 247 118  // 0-based index
 sunday | 258;107 // 0-based index
  • \$\begingroup\$ If anyone can come up with a more pun title, feel free to change it. \$\endgroup\$
    – lolbas
    Mar 10, 2019 at 15:06
  • 2
    \$\begingroup\$ So this can be hardcoded? \$\endgroup\$
    – Quintec
    Mar 10, 2019 at 15:24
  • \$\begingroup\$ @Quintec and I was hoping I thought of everything... I generalized the challenge. \$\endgroup\$
    – lolbas
    Mar 10, 2019 at 15:36
  • \$\begingroup\$ Must we assume that the months work like in the Gregorian calendar? Like, are there 7 months with 31 days, 4 months with 30 days and 1 month with 28 days? \$\endgroup\$ Mar 10, 2019 at 21:11
  • \$\begingroup\$ @EriktheOutgolfer I thought about adding an arbitrary length of months to make it more challenging and now that one of the ways is to precalculate most of the values I see I should have done that... But yea, your assumption is correct. \$\endgroup\$
    – lolbas
    Mar 11, 2019 at 8:32

4 Answers 4


Python 3.8 (pre-release), 37 bytes

lambda d:(k:=ord('```grvk'[d]),365-k)

Monday is 0, returns a tuple (weekend days, weekdays).

Try it online!


JavaScript (ES6),  34  33 bytes

Takes input as a 0-based index. Returns [weekend_days, working_days].


Try it online!


The minimum number of weekend days \$w_i\$ being \$96\$, we can just store the difference \$d_i=w_i-96\$ for each possible input and output \$[96+d_i, 365-(96+d_i)]\$.

This gives:


It's worth noting that \$96=2^5+2^6\$ and each value above is less than \$2^5\$, which means that we can compute \$96\text{ OR }d_i\$ instead of \$96+d_i\$ and still get the correct result.

We use the following formula to convert \$i\$ to \$d_i\$:

$$d_i=(x_i\times11)\bmod 24$$

where \$x_i\$ consists of a single decimal digit:


Hence the JS code:

96 | '5621'[d - 3] * 11 % 24

For \$i<3\$, '5621'[d-3] is undefined and '5621'[d-3]*11%24 results in NaN. But because we use a bitwise OR, this is coerced to \$0\$ and returns \$96\$ as expected.


Jelly,  16  15 bytes

-1 thanks to Erik the Outgolfer (use of printing in a full-program mode)


Monday is 1, prints weekend days then weekdays to STDOUT.

Try it online!

I am not sure how to build data for Jelly's hash function, , but maybe that would be better...

  • \$\begingroup\$ I don't think the hash function will be better, as you'd still need to include the “```grvk‘ list in the left argument. However, you can save a byte by converting this to a full program (;365ạ\Ṅ365_). \$\endgroup\$ Mar 11, 2019 at 11:23
  • \$\begingroup\$ I thought one could use the inputs as the keys with some salt that produces the right numbers by search (the option to take the day name would work best I guess); the salt could be bigger though... Anyway I don't know how any of the code works or how to use the C++ code on the branch - if you have some time maybe you can work that out. Nice golf using printing, thanks! \$\endgroup\$ Mar 11, 2019 at 11:39

05AB1E, 17 bytes


0-indexed (0 = Monday; 6 = Sunday), returns [working_days, weekend_days].

Try it online or verify all test cases.


.•OζΛ¦•            # Push compressed string "aaahswl"
       Iè          # Index the input-integer into it
         Ç         # Convert the character to its unicode value
          <        # Decrease that by 1
           D365α   # Create a copy, and get its absolute difference with 365
                ì  # Prepend this (and output the result implicitly)

See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•OζΛ¦• is "aaahswl".


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.