# Shana tova umetuka! (Happy Jewish New Year!)

Write the shortest program, in the language of your choice, that takes as input a year on the Hebrew calendar, and outputs the corresponding Gregorian date for Rosh Hashana, in YYYY-MM-DD format.

~$rh 5771 2010-09-09 ~$ rh 5772
2011-09-29
~$rh 5773 2012-09-17  • The input may come from either the command line or from stdin, whichever is more convenient. • You may assume that the year will be between 5600 (1839) and 6000 (2239), inclusive. • @trinithis i beg your pardon, dude. the Hebrew calendar was inherited from the Babylonian system of computing ephemerides. this guy figured that out: en.wikipedia.org/wiki/Otto_Neugebauer it is a very cool piece of precognate almagestian mathematics worthy of study by any geek worth his unix pipe Sep 22, 2011 at 22:10 ## 3 Answers ### Ruby, 192181 165 characters require'date' s=(-6+235*n=gets.to_i)/19*765433+73848;e=s/u=25920$><<Date.jd(347641+e+([h=s%u/19440,84>>e%7+h&1,v=e%7*(374454>>n%19&1-h&s%u/9923),v,n-5765].count 1))


Input is given as a single number on STDIN.

Edit 1: Several arithmetic transformations saved quite a few characters.

Edit 2: There was some room for improvement.

## C#, 212

This might seem cheap, but here I go:

using System;using System.Globalization;class P{static void Main(){int y=int.Parse(Console.ReadLine())-5771;var a=new HebrewCalendar().AddYears(new DateTime(2010,9,9),y);Console.Write(a.ToString("yyyy-MM-dd"));}}


with spacing

using System;
using System.Globalization;
class P
{
static void Main()
{
int y = int.Parse(Console.ReadLine()) - 5771;
var a = new HebrewCalendar().AddYears(new DateTime(2010, 9, 9), y);
Console.Write(a.ToString("yyyy-MM-dd"));
}
}

• You could save one character by using 5771 as your reference year instead of 5772. Sep 19, 2011 at 13:33
• @dan04 Done.... Sep 19, 2011 at 13:36
• You shouldn't count Console.Read(); as a part of the program, it's not really needed.
– user1158
Sep 20, 2011 at 14:48
• @PeterOlson Here's a version at only 190 bytes: using System;class P{static void Main(){Console.Write(new System.Globalization.HebrewCalendar().AddYears(new DateTime(2010,9,9),int.Parse(Console.ReadLine())-5771).ToString("yyyy-MM-dd"));}}. Feb 19, 2014 at 17:00

## CPAN 5.10, 109

This is even cheaper than the C# solution, for reasons enumerated below. Code first: (character count as a difference to perl -E'' as usual)

$perl -E'$_="DateTime::Calendar::Hebrew";/:/;eval"require $_";say$->from_object(object,\$_->new(year,<>,month,7))->ymd'

• steals Peter Olson's idea of just outsourcing it to the library
• CPAN's current release of DateTime::Calendar::Hebrew` doesn't install out of the box, you need to patch it.
• needs Perl 5.10. No earlier, no later.

At least it's short.