Skip to content

Instantly share code, notes, and snippets.

View jalcoding8's full-sized avatar

Jeanine L jalcoding8

View GitHub Profile
@jalcoding8
jalcoding8 / hanoi.py
Last active January 25, 2021 17:56
Towers of Hanoi Python3
from stack import Stack
print("\nLet's play Towers of Hanoi!!")
#Create the Stacks
stacks = []
left_stack = Stack("Left")
middle_stack = Stack("Middle")
right_stack = Stack("Right")
stacks += [left_stack, middle_stack, right_stack]
@jalcoding8
jalcoding8 / min_heap.py
Last active January 25, 2021 17:55
Min Heap
class MinHeap:
def __init__(self):
self.heap_list = [None]
self.count = 0
# HEAP HELPER METHODS
# DO NOT CHANGE!
def parent_idx(self, idx):
return idx // 2
import random
name = "Zebra"
question = "Will I grow wings?"
answer = ""
random_number = random.randint(1, 11)
#print(random_number)
if random_number == 1:
import random
name = "Zebra"
question = "Will I grow wings?"
answer = ""
random_number = random.randint(1, 11)
#print(random_number)
if random_number == 1:
@jalcoding8
jalcoding8 / shipping.py
Created January 25, 2021 18:01
Control Flow python3
weight = 4.8
#weight = 41.5
#weight = 1.5
print("Ground Shipping")
if weight <= 2:
ground_cost = weight * 1.50 + 20
elif weight > 2 and weight <= 6:
ground_cost = weight * 3.00 + 20
# We'll be using our Node class
class Node:
def __init__(self, value, next_node=None):
self.value = value
self.next_node = next_node
def get_value(self):
return self.value
def get_next_node(self):
@jalcoding8
jalcoding8 / Rock, paper, scissors
Created May 26, 2021 15:37
JavaScript arrow functions
const getUserChoice = (userChoice) => {
userChoice = userChoice.toLowerCase();
if (userChoice === 'rock' || userChoice === 'paper' || userChoice === 'scissors') {
return userChoice;
} else {
console.log(userChoice);
return 'Invalid choice';
}
};
@jalcoding8
jalcoding8 / script.js
Created June 2, 2021 19:29
number-guesser/JavaScript
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
// Write your code below:
const generateTarget = () => {
return Math.floor(Math.random() *10);
};
const alert = humanGuess => {
// All valid credit card numbers
const valid1 = [4, 5, 3, 9, 6, 7, 7, 9, 0, 8, 0, 1, 6, 8, 0, 8];
const valid2 = [5, 5, 3, 5, 7, 6, 6, 7, 6, 8, 7, 5, 1, 4, 3, 9];
const valid3 = [3, 7, 1, 6, 1, 2, 0, 1, 9, 9, 8, 5, 2, 3, 6];
const valid4 = [6, 0, 1, 1, 1, 4, 4, 3, 4, 0, 6, 8, 2, 9, 0, 5];
const valid5 = [4, 5, 3, 9, 4, 0, 4, 9, 6, 7, 8, 6, 9, 6, 6, 6];
// All invalid credit card numbers
const invalid1 = [4, 5, 3, 2, 7, 7, 8, 7, 7, 1, 0, 9, 1, 7, 9, 5];
const invalid2 = [5, 7, 9, 5, 5, 9, 3, 3, 9, 2, 1, 3, 4, 6, 4, 3];
@jalcoding8
jalcoding8 / main.js
Last active July 28, 2021 15:10
Javascript - Mysterious Organism(DNA) syntax Project
// Returns a random DNA base
const returnRandBase = () => {
const dnaBases = ['A', 'T', 'C', 'G']
return dnaBases[Math.floor(Math.random() * 4)]
};
// Returns a random single stand of DNA containing 15 bases
const mockUpStrand = () => {
const newStrand = []
for (let i = 0; i < 15; i++) {