Skyglobe for MSDOS, still the best astronomy software 35 years later…
Before we wasted time on Windows solitaire we wasted time on MSDOS solitaire.
Skyglobe for MSDOS, still the best astronomy software 35 years later…
Before we wasted time on Windows solitaire we wasted time on MSDOS solitaire.
while :;do echo $LINES $COLUMNS $((RANDOM%COLUMNS)) $(printf '%b' "\\u$(printf '%04x' $((RANDOM%500)))");sleep .05;done|gawk '{a[$3]=0;for(x in a){o=a[x];a[x]++;printf "\033[%s;%sH\033[2;32m%s",o,x,$4;printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,$4;if(a[x]>=$1)a[x]=0}}'
Generate magic squares for any odd side length:
#!/usr/bin/env python3
import sys
def magic_constant(n):
return n * (n * n + 1) // 2
def magic_square(n):
square = [[0] * n for _ in range(n)]
num = 1
i, j = 0, n // 2
while num <= n * n:
square[i][j] = num
num += 1
new_i = (i - 1) % n
new_j = (j + 1) % n
if square[new_i][new_j]:
i = (i + 1) % n
else:
i, j = new_i, new_j
return square
n = int(sys.argv[1]) if len(sys.argv) > 1 else 3
square = magic_square(n)
width = len(str(n * n))
print(f"Magic constant for n={n}: {magic_constant(n)}\n")
for row in square:
print(" ".join(f"{x:>{width}}" for x in row))
Print a list of last Fridays every month for the given year
#!/usr/bin/python3
import sys
from calendar import monthrange
from datetime import date, timedelta
def last_fridays(year):
for month in range(1, 13):
last_day = date(year, month, monthrange(year, month)[1])
yield last_day - timedelta(days=(last_day.weekday() - 4) % 7)
for friday in last_fridays(int(sys.argv[1])):
print(friday.isoformat())
Print a list of antiprimes (highly composite numbers) with bc
#! /usr/bin/bc
define factors(n) {
auto c, i
for(i=1;i<=n;i++) {
if(n%i==0) c+=1
}
return c
}
max = 0
n = 1
for(c=19; c > 0;) {
f = factors(n)
if(f > max) {
print n," "
max = f
c -= 1
}
n += 1
}
print "\n"
quit
BEGIN {
for (i=1; i <= r; i++) {
A[i] = i
if (i < r ) printf i OFS
else print i}
while (A[1] < n - r + 1) {
for (i = r; i >= 1; i--) {
if (A[i] < n - r + i) {
A[i]++
p = i
break}}
for (i = p + 1; i <= r; i++) A[i] = A[i - 1] + 1
for (i=1; i <= r; i++) {
if (i < r) printf A[i] OFS
else print A[i]}}
exit}
#!/usr/bin/python3
import sys
with open(sys.argv[1], "rb") as f:
data = f.read()
for offset in range(0, len(data), 16):
b = data[offset:offset + 16]
left = " ".join(f"{x:02x}" for x in b[:8])
right = " ".join(f"{x:02x}" for x in b[8:])
hexpart = f"{left:<23} {right:<23}"
text = "".join(chr(x) if 32 <= x <= 126 else "." for x in b)
print(f"{offset:08x} {hexpart} |{text}|")