Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
4
Task/Long-year/UNIX-Shell/long-year-1.sh
Normal file
4
Task/Long-year/UNIX-Shell/long-year-1.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
long_year() {
|
||||
cal 1 $1 | grep -q ' 3 *$' && return 0
|
||||
cal 12 $1 | grep -q ' 26 *$'
|
||||
}
|
||||
3
Task/Long-year/UNIX-Shell/long-year-2.sh
Normal file
3
Task/Long-year/UNIX-Shell/long-year-2.sh
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
long_year() {
|
||||
expr $(date -d "$1-12-28" +%V) = 53 >/dev/null
|
||||
}
|
||||
12
Task/Long-year/UNIX-Shell/long-year-3.sh
Normal file
12
Task/Long-year/UNIX-Shell/long-year-3.sh
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
dec31wd() {
|
||||
# return weekday (time_t tm_wday, 0=Sunday) of December 31st of the given year
|
||||
typeset -i y=$1
|
||||
echo $(( (y + y / 4 - y / 100 + y / 400) % 7 ))
|
||||
}
|
||||
|
||||
# the year is long if the year starts or ends on a Thursday (starts on a
|
||||
# Thursday = the previous year ends on a Wednesday)
|
||||
long_year() {
|
||||
typeset -i y=$1
|
||||
(( 4 == $(dec31wd $y) || 3 == $(dec31wd $(( y - 1 ))) ))
|
||||
}
|
||||
5
Task/Long-year/UNIX-Shell/long-year-4.sh
Normal file
5
Task/Long-year/UNIX-Shell/long-year-4.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
for y in $(seq 1995 2045); do
|
||||
if long_year $y; then
|
||||
echo $y
|
||||
fi
|
||||
done | column
|
||||
Loading…
Add table
Add a link
Reference in a new issue