RosettaCodeData/Task/Five-weekends/Amazing-Hopper/five-weekends-2.hopper

36 lines
1.1 KiB
Plaintext

#include <jambo.h>
#define __PRNNL__ {"\n"}print
#synon __PRNNL__ *Print it
#synon Set *Set
Main
Set stack 15
Init zero (candidato, total, sin weekend largo, sw, columna, fecha)
/* Configura meses */
mes largo = {}
Let list ( mes largo := 1, 3, 5, 7, 8, 10, 12 )
/* Busca los meses con weekend larguísimo */
Loop for (año = 1900, #( año <= 2100), ++año)
Loop for( i=1, #(i<=7), ++i)
Let ( candidato := [i] Of 'mes largo' )
Let ( fecha := Multicat ("1/",Str(candidato),"/",Str(año)) )
When ( Strday 'fecha' Is equal to '"Viernes"', \
And ( Days of month 'fecha' Compared to '31', Are equals? )) {
++total, sw=1
Print (año," : ", Just left (13, Month name 'candidato')," | ")
When ( columna++ Is equal to '3' ) { Prnl, columna=0 }
}
Back
When ( Not( sw ) ) { ++ sin weekend largo }, sw=0
Back
now Set ( Utf8("\nTotal de años con weekend de 5 días = "), total )
and Set ( Utf8("\nAños sin weekend de 5 días: "), sin weekend largo) then Print it
End