Skip to content

Instantly share code, notes, and snippets.

View mrdoornbos's full-sized avatar

Michael Doornbos mrdoornbos

View GitHub Profile
@mrdoornbos
mrdoornbos / ten.py
Created November 23, 2023 14:46
Numworks one line 10PRINT
import random; counter = 0; exec("while True: print(random.choice('/' + chr(92)), end='' if (counter := counter + 1) % 80 else '\\n')")
pack_sizes = [4, 6, 10, 20, 40]
max_search_range = max(pack_sizes) * 3 # Heuristic to ensure we cover enough range
possible_totals = set([0]) # Initialize with 0, as we can always buy 0 McNuggets
# Iteratively find all possible totals that can be made with given pack sizes
for pack_size in pack_sizes:
new_totals = set()
for total in possible_totals:
new_total = total
while new_total <= max_search_range:
10 TI$="000000"
100 DIM P(240)
110 FOR I = 0 TO 240: P(I) = 0: NEXT
120 FOR A = 0 TO 240 STEP 4
130 FOR B = 0 TO 240 STEP 6
140 FOR C = 0 TO 240 STEP 10
150 FOR D = 0 TO 240 STEP 20
160 FOR E = 0 TO 240 STEP 40
170 T = A + B + C + D + E
180 IF T <= 240 THEN P(T) = 1
@mrdoornbos
mrdoornbos / check_xz_version.yml
Created March 30, 2024 11:44
Ansible Playbook to Check xz version is
---
- name: Check xz version on servers
hosts: all
tasks:
- name: Get xz version
shell: xz --version | head -n1 | awk '{print $NF}' # Using $NF to capture the last field which is expected to be the version number
register: xz_version_output
changed_when: False
ignore_errors: True
@mrdoornbos
mrdoornbos / tenprint.f90
Created May 27, 2024 17:59
classic 10 print in gfortran, just for the haters
program ten_print
implicit none
integer :: i, j
integer, parameter :: n = 40
call random_seed()
do i = 1, n
do j = 1, n
if (rand() < 0.5) then
@mrdoornbos
mrdoornbos / gist:7eb8980de241d6fdd4ee7ffa09e0d4cd
Last active November 18, 2024 22:04
Calculators with a dedicated or shifted Int button for the integer function
HP 15C
HP 12C
HP 300s+
HP 65
Casio FX-502P
Casio FX-880
Casio FX-850