2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,4 +1,6 @@
|
|||
Provide an algorithm as per the [[Calendar]] task, except the entire code for the algorithm must be presented entirely without lowercase.
|
||||
;Task:
|
||||
Provide an algorithm as per the [[Calendar]] task, except the entire code for the algorithm must be presented ''entirely without lowercase''.
|
||||
|
||||
Also - as per many 1969 era [[wp:line printer#Paper (forms) handling|line printer]]s - format the calendar to nicely fill a page that is 132 characters wide.
|
||||
|
||||
(Hint: manually convert the code from the [[Calendar]] task to all UPPERCASE)
|
||||
|
|
@ -24,3 +26,6 @@ For economy of size, do not actually include Snoopy generation
|
|||
in either the code or the output, instead just output a place-holder.
|
||||
|
||||
FYI: a nice ASCII art file of Snoopy can be found at [http://www.textfiles.com/artscene/asciiart/cursepic.art textfiles.com]. Save with a .txt extension.
|
||||
|
||||
'''Trivia:''' The terms uppercase and lowercase date back to the early days of the mechanical printing press. Individual metal alloy casts of each needed letter, or punctuation symbol, were meticulously added to a press block, by hand, before rolling out copies of a page. These metal casts were stored and organized in wooden cases. The more often needed ''miniscule'' letters were placed closer to hand, in the lower cases of the work bench. The less often needed, capitalized, ''majiscule'' letters, ended up in the harder to reach upper cases.
|
||||
<br><br>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#define system.
|
||||
#define system'text.
|
||||
#define system'routines.
|
||||
#define system'calendar.
|
||||
#define extensions.
|
||||
#define extensions'math.
|
||||
#define extensions'routines.
|
||||
#import system.
|
||||
#import system'text.
|
||||
#import system'routines.
|
||||
#import system'calendar.
|
||||
#import extensions.
|
||||
#import extensions'math.
|
||||
#import extensions'routines.
|
||||
|
||||
#symbol MonthNames = ("JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER").
|
||||
#symbol DayNames = ("MO", "TU", "WE", "TH", "FR", "SA", "SU").
|
||||
|
|
@ -44,7 +44,6 @@
|
|||
control do:
|
||||
[
|
||||
theLine write:(theDate day literal) &paddingLeft:3 &with:#32.
|
||||
|
||||
theDate := theDate add &days:1.
|
||||
]
|
||||
&until:[(theDate month != theMonth)or:[theDate dayOfWeek == 1]].
|
||||
|
|
@ -71,7 +70,6 @@
|
|||
#loop (anIndex > theRow) ?
|
||||
[ self writeLine. ].
|
||||
]
|
||||
|
||||
get = self.
|
||||
}.
|
||||
|
||||
|
|
@ -114,7 +112,6 @@
|
|||
aRow run &each: aMonth
|
||||
[
|
||||
aMonth printTitleTo:anOutput.
|
||||
|
||||
anOutput write:" ".
|
||||
].
|
||||
|
||||
|
|
@ -125,10 +122,8 @@
|
|||
aLine run &each: aPrinter
|
||||
[
|
||||
aPrinter printTo:anOutput.
|
||||
|
||||
anOutput write:" ".
|
||||
].
|
||||
|
||||
anOutput writeLine.
|
||||
].
|
||||
].
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
FUNCTION PRINT_CAL(YEAR)
|
||||
LOCAL MONTHS={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE",
|
||||
"JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"}
|
||||
LOCAL DAYSTITLE="MO TU WE TH FR SA SU"
|
||||
LOCAL DAYSPERMONTH={31,28,31,30,31,30,31,31,30,31,30,31}
|
||||
LOCAL STARTDAY=((YEAR-1)*365+MATH.FLOOR((YEAR-1)/4)-MATH.FLOOR((YEAR-1)/100)+MATH.FLOOR((YEAR-1)/400))%7
|
||||
IF YEAR%4==0 AND YEAR%100~=0 OR YEAR%400==0 THEN
|
||||
DAYSPERMONTH[2]=29
|
||||
END
|
||||
LOCAL SEP=5
|
||||
LOCAL MONTHWIDTH=DAYSTITLE:LEN()
|
||||
LOCAL CALWIDTH=3*MONTHWIDTH+2*SEP
|
||||
|
||||
FUNCTION CENTER(STR, WIDTH)
|
||||
LOCAL FILL1=MATH.FLOOR((WIDTH-STR:LEN())/2)
|
||||
LOCAL FILL2=WIDTH-STR:LEN()-FILL1
|
||||
RETURN STRING.REP(" ",FILL1)..STR..STRING.REP(" ",FILL2)
|
||||
END
|
||||
|
||||
FUNCTION MAKEMONTH(NAME, SKIP,DAYS)
|
||||
LOCAL CAL={
|
||||
CENTER(NAME,MONTHWIDTH),
|
||||
DAYSTITLE
|
||||
}
|
||||
LOCAL CURDAY=1-SKIP
|
||||
WHILE #CAL<9 DO
|
||||
LINE={}
|
||||
FOR I=1,7 DO
|
||||
IF CURDAY<1 OR CURDAY>DAYS THEN
|
||||
LINE[I]=" "
|
||||
ELSE
|
||||
LINE[I]=STRING.FORMAT("%2D",CURDAY)
|
||||
END
|
||||
CURDAY=CURDAY+1
|
||||
END
|
||||
CAL[#CAL+1]=TABLE.CONCAT(LINE," ")
|
||||
END
|
||||
RETURN CAL
|
||||
END
|
||||
|
||||
LOCAL CALENDAR={}
|
||||
FOR I,MONTH IN IPAIRS(MONTHS) DO
|
||||
LOCAL DPM=DAYSPERMONTH[I]
|
||||
CALENDAR[I]=MAKEMONTH(MONTH, STARTDAY, DPM)
|
||||
STARTDAY=(STARTDAY+DPM)%7
|
||||
END
|
||||
|
||||
|
||||
PRINT(CENTER("[SNOOPY]",CALWIDTH):UPPER(),"\N")
|
||||
PRINT(CENTER("--- "..YEAR.." ---",CALWIDTH):UPPER(),"\N")
|
||||
|
||||
FOR Q=0,3 DO
|
||||
FOR L=1,9 DO
|
||||
LINE={}
|
||||
FOR M=1,3 DO
|
||||
LINE[M]=CALENDAR[Q*3+M][L]
|
||||
END
|
||||
PRINT(TABLE.CONCAT(LINE,STRING.REP(" ",SEP)):UPPER())
|
||||
END
|
||||
END
|
||||
END
|
||||
|
||||
PRINT_CAL(1969)
|
||||
|
|
@ -0,0 +1 @@
|
|||
do io.input( arg[ 1 ] ); local s = io.read( "*a" ):lower(); io.close(); assert( load( s ) )() end
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
$_=["\0"..."~"];<
|
||||
114 117 110 32 34 99 97 116 32 115 110 111 111 112 121 46
|
||||
116 120 116 59 99 97 108 32 64 42 65 82 71 83 91 48 93 34
|
||||
>."$_[99]$_[104]$_[114]$_[115]"()."$_[101]$_[118]$_[97]$_[108]"()
|
||||
$_="\0".."~";<
|
||||
115 97 121 32 34 91 73 78 83 69 82 84 32 83 78 79 79 80 89 32 72 69 82 69 93 34
|
||||
59 114 117 110 32 60 99 97 108 62 44 64 42 65 82 71 83 91 48 93 47 47 49 57 54 57
|
||||
>."$_[99]$_[104]$_[114]$_[115]"()."$_[69]$_[86]$_[65]$_[76]"()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
import subprocess
|
||||
px = subprocess.Popen(['python', '-c', 'import calendar; calendar.prcal(1969)'],
|
||||
stdout=subprocess.PIPE)
|
||||
cal = px.communicate()[0]
|
||||
print cal.upper()
|
||||
Loading…
Add table
Add a link
Reference in a new issue