Skip to content

Instantly share code, notes, and snippets.

View RobertTalbert's full-sized avatar

Robert Talbert RobertTalbert

View GitHub Profile
# List of trails in North Ottawa Dunes park given as tuples.
# Vertex 100 = Trailhead in Coast Guard Park
# Vertex 200 = Trailhead at North Beach Park
# Vertex 300 = Trail endpoint at Hoffmaster State Park
[(100,1,.30), (1,24,.16), (1,2,.20), (2,19,.11), (19,25,.07),
(19,20,.16), (20,200, .16), (2,3,.49), (3,23,.11), (3,4,.34),
(4,23,.34), (4,18,.07), (4,21,.22), (5,21,.09), (5,6,.16),
(5,15,.23), (6,7,.34), (6,16,.07), (7,12,.12), (7,8,.15), (8,9,.21),
(8,13,.25), (9,10,.06), (10,11,.21), (10,12,.51), (11,300,.12),
# Generate a random tree
random_tree = nx.random_tree(n)
# Draw the tree
nx.draw(random_tree, with_labels=True, node_color="lightblue", font_weight="bold")
plt.show()
# Python code for MTH 325 F24 Homework 5
## 1. Iterating through a list
vertex_list = [(2,3), (2,4), (4,5), (1,3)]
for vertex in vertex_list:
print(vertex[1])
## 2. A dictionary
# Libraries
library(dplyr)
library(tidyverse)
library(ggplot2)
# Load data
colnames <- c("time", "email", "name", "section",
"challenge", "support",
"competence", "autonomy", "relatedness",
aliases

(insert tags here)

Definition

[!tldr] Definition Contents

# Use basic logic commands to "fake" set operations.
# Here's union:
U = [1,2,3,4,5,6,7,8,9,10]
A = [1,2,3,4,5,6]
B = [2,4,6]
# A union B
[x for x in U if ((x in A) or (x in B))]
# Recursive functions for MTH 225 9/25/2023
# Input is a positive integer
def A(n):
if n == 1:
return n
else:
return n + A(n-1)
# Input is a positive integer
@RobertTalbert
RobertTalbert / collatz.py
Created August 28, 2023 13:54
Python code for exploring the Collatz conjecture
# Individual Collatz computation
def f(n):
if n % 2 == 0:
return n//2
else:
return 3*n+1
# Create sequence of integers from the Collatz function
# This assumes the Collatz conjecture is true LOL
def collatz(n):
  1. Generosity: Give wealth, time, and attention when and where others can be well served by it.
  2. Charity: Look out not only for your own interests, but also the interests of others.
  3. Leadership: Build your influence and use it to make a positive difference.
  4. Balance: Live as a whole person with a multifaceted, multidimensional life.
  5. Health: Build and maintain your physical, emotional, and spiritual self.
  6. Curiosity: Seek out and pursue interesting things and never stop learning.
  7. Adventure: Take risks, seek out new experiences, and pursue growth without fear.
  8. Humor: Keep perspective, don't take yourself too seriously, and have fun.
  9. Persistence: Honor your commitments, finish what you start, and don't give up.
  10. Faith: Love God with all your heart, sould, mind, and strength -- and respond to Him with trust.