Skip to content

Instantly share code, notes, and snippets.

@epochblue
Last active August 14, 2018 11:08
Show Gist options
  • Save epochblue/0cc28845d91bb0477c1560d8fbbb136e to your computer and use it in GitHub Desktop.
Save epochblue/0cc28845d91bb0477c1560d8fbbb136e to your computer and use it in GitHub Desktop.
Start script for generating random-ish HIIT workouts
#!/usr/bin/env python3
"""
Builds a simple HIIT workout, while trying to be
smart about how it builds it.
Author: Bill Israel <[email protected]>
License: Public Domain
"""
import random
import sys
import textwrap
CARDIO = [
'High-Knee Running',
'Butt Kicks',
'Skier Jumps',
'Jumping Jacks',
'Mountain Climbers',
'Burpees',
'Step Ups',
'Box Jumps',
'Jump Rope',
]
ARMS = [
'Push-ups',
'Spider-Man Pushups',
'Tricep Dip',
'Judo Push-up',
'Push-ups with Rotation',
'Curls',
'Alternating Row',
]
LEGS = [
'Squats',
'Squat Jumps',
'Squat Jacks',
'Plie Squats',
'Lunges',
'Ice Skaters',
'Calf Raises',
'Wall Sit',
'Glute Bridges',
'Split Squat',
'Romanian Dead Lift',
]
ABS = [
'Abdominal Crunches',
'Plank',
'Side Plank',
'Side Plank Dip',
'Bicycle Crunch',
'Double Leg Lift',
'Russian Twist',
'Flutter Kick',
'Supermans',
]
REQUIRES_EQUIPMENT = {
'Box Jumps': ['Bench or chair'],
'Tricep Dip': ['Bench or chair'],
'Curls': ['Dumbells or resistance bands'],
'Step-Ups': ['Bench or chair'],
'Jump Rope': ['Jump rope'],
'Romanian Dead Lift': ['Weighted bar'],
'Alternating Row': ['Dumbells'],
}
SPLIT_EXERCISES = [
'Side Plank',
'Side Plank Dip',
]
CIRCUIT = [CARDIO, ARMS, LEGS, ABS] * 3
NUM_CIRCUITS = 2
def choose_and_remove_exercise(slot):
chosen_exercise = random.choice(slot)
slot.remove(chosen_exercise)
return chosen_exercise
def generate_circuits():
circuits = []
equipment_needed = set()
for i in range(NUM_CIRCUITS):
chosen_exercises = []
for slot in CIRCUIT:
chosen_exercise = choose_and_remove_exercise(slot)
if chosen_exercise in SPLIT_EXERCISES:
splits = [f'Left {chosen_exercise}', f'Right {chosen_exercise}']
chosen_exercises.extend(splits)
else:
chosen_exercises.append(chosen_exercise)
if len(chosen_exercises) != 13:
chosen_exercises.append(choose_and_remove_exercise(CARDIO))
circuits.append(chosen_exercises)
for exercise in chosen_exercises:
if exercise in REQUIRES_EQUIPMENT:
equipment_needed.update(REQUIRES_EQUIPMENT[exercise])
return circuits, equipment_needed
def print_workout(circuits, eqipment_needed, print_equipment=False):
print('# Today\'s Workout:')
for idx, circuit in enumerate(circuits, start=1):
print(f'\n## Circuit {idx}:\n')
for ex_idx, exercise in enumerate(circuit, start=1):
print(f'{ex_idx}. {exercise}')
if print_equipment and equipment_needed:
print('\n## Equipment needed:\n')
for piece in equipment_needed:
print(f'* {piece}')
def print_usage():
print(textwrap.dedent(f'''\
usage: {sys.argv[0]} [options]
options:
-e, --equipment Print needed equipment
-h, --help Show this message
'''))
if __name__ == '__main__':
print_equipment = False
if len(sys.argv) > 1:
arguments = sys.argv[1:]
for argument in arguments:
if argument in ['-h', '--help']:
print_usage()
sys.exit(0)
elif argument in ['-e', '--equipment']:
print_equipment = True
else:
print(f'Error: unknown argument "{argument}"')
print_usage()
sys.exit(1)
circuits, equipment_needed = generate_circuits()
print_workout(circuits, equipment_needed, print_equipment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment