Calendar

Display calendar for specific month and year. Like unix util cal.

IN

12 2014

OUT

Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

IN

6 2018

OUT

Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

IN

1 2000

OUT

Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

IN

3 1998

OUT

Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Login to submit solution


63 symbols pyth
Thu Nov 3 18:09:59 2016 Sait2000
.vCim-id64^964 2cCM"ᑜ峨룦鬿䳠᭑䨕ᩕ乖㺆㎿ꞎ徜怯﯄穉㒍䘅乛䁮싔ﲱᚕ룑ꇴ闭淡돝苐杓"3 69948
67 symbols pyth
Thu Nov 17 03:29:15 2016 Sait2000
>Jv+"__import__('calendar').TextCalendar(6).formatmonth"`(F_rz7xJ\S
70 symbols pyth
Fri Oct 21 19:14:14 2016 Sait2000
>Jv%"__import__('calendar').TextCalendar(6).formatmonth(*%s)"`_rz7xJ\S
108 symbols python3
Wed Sep 21 05:53:54 2016 Sait2000
import calendar as c
r=c.TextCalendar(6).formatmonth(*map(int,input().split()[::-1]))
print(r[r.find("S"):])
109 symbols python3
Mon Sep 19 13:51:33 2016 Sait2000
import calendar as c
a,b=map(int,input().split())
r=c.TextCalendar(6).formatmonth(b,a)
print(r[r.find("S"):])
114 symbols python2
Thu Feb 19 22:19:33 2015 PFischbeck
import calendar as c
[a,b]=map(int,raw_input().split())
r=c.TextCalendar(6).formatmonth(b,a)
print r[r.find("S"):]
116 symbols python2
Thu Feb 19 22:18:45 2015 PFischbeck
import calendar as c
i=map(int,raw_input().split())
r=c.TextCalendar(6).formatmonth(i[1],i[0])
print r[r.find("S"):]
118 symbols python2
Thu Feb 19 22:16:15 2015 PFischbeck
import calendar
i=map(int,raw_input().split())
r=calendar.TextCalendar(6).formatmonth(i[1],i[0])
print r[r.find("S"):]
126 symbols python3
Thu Feb 19 17:00:16 2015 k-popov
import calendar; i=input().split();print("\n".join(calendar.TextCalendar(6).formatmonth(int(i[1]),int(i[0])).split("\n")[1:]))
167 symbols ruby2.0
Mon Jan 5 16:35:33 2015 vakorol
#!/usr/bin/ruby1.9.1 -ap
require'date'
m,y=$F.map &:to_i
d=Date.new y,m
$_="Su Mo Tu We Th Fr Sa\n"+'   '*d.wday
while$_+=sprintf("%2d",d.day)
d+=1
d.mon!=m&&break
$_+=d.wday>0?' ':"\n"
end
168 symbols ruby2.0
Mon Jan 5 16:11:54 2015 vakorol
#!/usr/bin/ruby1.9.1 -ap
require'date'
m,y=$F.map &:to_i
d=Date.new y,m
$_="Su Mo Tu We Th Fr Sa\n"+'   '*d.wday
while 1
$_+=sprintf"%2d",d.day
d+=1
d.mon!=m&&break
$_+=d.wday>0?' ':"\n"
end
174 symbols ruby2.0
Mon Jan 5 16:02:06 2015 vakorol
#!/usr/bin/ruby1.9.1
require'date'
m,y=gets.split.map &:to_i
d=Date.new y,m
puts'Su Mo Tu We Th Fr Sa'
print'   '*d.wday
while 1
printf"%2d",d.day
d+=1
d.mon!=m&&break
print d.wday>0?' ':"\n"
end
208 symbols perl
Sun Jan 11 21:20:09 2015 danieljabailey
#!/usr/bin/perl -n
use Time::Piece;$t=Time::Piece->strptime($_, "%m %Y\n");$y=$t->add_months(1);$d=($y-$t)/86400;$w=$t->day_of_week;print"Su Mo Tu We Th Fr Sa\n"."   "x$w;printf"%2.d".(($w+$_)%7&&$_<$d?" ":"\n"),$_ for(1..$d)
210 symbols perl
Sun Jan 11 21:18:08 2015 danieljabailey
#!/usr/bin/perl -n
use Time::Piece;$t=Time::Piece->strptime("$_", "%m %Y\n");$y=$t->add_months(1);$d=($y-$t)/86400;$w=$t->day_of_week;print"Su Mo Tu We Th Fr Sa\n"."   "x$w;printf"%2.d".(($w+$_)%7&&$_<$d?" ":"\n"),$_ for(1..$d)
387 symbols haskell
Sat Mar 14 14:13:11 2015 YoshikuniJujo
import Data.Time
import Data.Time.Calendar.MonthDay
import Data.Time.Calendar.WeekDate
main=interact$unlines.("Su Mo Tu We Th Fr Sa":).map(tail.(w=<<)).(\[m,y]->c$read m#read y).words
r=replicate
m#y=(d`mod`7,monthLength(isLeapYear y)m)where(_,_,d)=toWeekDate$fromGregorian y m 1
c(d,l)=p 7$r d 0++[1..l]
p _[]=[]
p n x=take n x:p n(drop n x)
w 0="   "
w x=r(3-length(show x))' '++show x

View all solutions