Skip to content

Instantly share code, notes, and snippets.

View jalcoding8's full-sized avatar

Jeanine L jalcoding8

View GitHub Profile
@jalcoding8
jalcoding8 / script.py
Last active March 29, 2024 16:52
Python hash_map delete issue
class HashMap:
def __init__(self, array_size):
self.array_size = array_size
self.array = [None for item in range(array_size)]
def hash(self, key, count_collisions=0):
key_bytes = key.encode()
hash_code = sum(key_bytes)
return hash_code + count_collisions
@jalcoding8
jalcoding8 / script-flatten-function.py
Last active November 23, 2022 16:08
Coding-Challenge-Python/Flatten-Array
def flatten_array(arr):
# Write your code here
flat_list = []
# Iterate through the outer list
for element in arr:
#if type(element) is list: #using type() to check for nested array OR
if isinstance(element, list): #using isinstance() to check for nested (multi-dimensional array
# If the element is of type list, iterate through the sublist or inner list
for item in element:
flat_list.append(item)
@jalcoding8
jalcoding8 / instructions.py
Created November 1, 2022 18:59
Coding Challenge - Python3
Reverse Words
Write a function, word_reverser(), that will take a given string and reverse the order of the words.
You may assume that the string is a sentence that contains only letters and spaces, with all words separated by one space.
For example, word_reverser("Codecademy rules") should return "rules Codecademy"
and word_reverser("May the Fourth be with you") should return "you with be Fourth the May".
@jalcoding8
jalcoding8 / encrpyptors.js
Last active April 27, 2022 17:30
Intermediate JavaScipt Message Mixer Project
const caesarCipher = (str, amount = 0) => {
if (amount < 0) {
return caesarCipher(str, amount + 26);
}
let output = '';
for (let i = 0; i < str.length; i++) {
let char = str[i];
if (char.match(/[a-z]/i)) {
let code = str.charCodeAt(i);
if (code >= 65 && code <= 90) {
@jalcoding8
jalcoding8 / app.js
Created February 25, 2022 17:55
Meal Planner Project - (Javascript Objects, with properties and methods)
//Task 1-13 and my own task 14
const menu = {
_courses: {
appetizers:[],
mains:[],
desserts:[],
},
get appetizers() {
return this._courses.appetizers;
},
@jalcoding8
jalcoding8 / script.py
Created January 27, 2022 16:19
python3-classes-Basta
#I added quite a bit of additional functionality so the project created more real world class instance objects
class Business:
def __init__(self, name, franchises):
self.name = name
self.franchises = []
class Franchise:
def __init__(self, address, menus, name):
self.address = address
@jalcoding8
jalcoding8 / happy_bday.txt
Last active January 6, 2022 18:35
Using python context managers
Forget about the past, you can’t change it.
Forget about the future, you can’t predict it.
And forget about the present, I didn’t get you one.
Happy birthday!
@jalcoding8
jalcoding8 / script.py
Created December 19, 2021 18:01
Building a python class context manager that will write and read file
class PoemFiles:
def __init__(self, poem_file, mode):
print('Starting up a poem context manager')
self.file = poem_file
self.mode = mode
def __enter__(self):
print('Opening poem file')
self.opened_poem_file = open(self.file, self.mode)
return self.opened_poem_file
@jalcoding8
jalcoding8 / NewTeacherInTown.py
Created October 1, 2021 16:01
working with iterables, iterators
#task 1
from roster import student_roster
import itertools
#task 2
from classroom_organizer import ClassroomOrganizer
new_student = ClassroomOrganizer()
student_roster_iterator = iter(student_roster)
print("task 1")
print("The full student roster (dictionary):")
@jalcoding8
jalcoding8 / jalcoding8-python3
Last active August 16, 2021 15:44
OOP/Encapsulation/getters-setters-delete
class Employee:
new_id = 1
def __init__(self, name=None):
self.id = Employee.new_id
Employee.new_id += 1
self._name = name
# Write your code below
def get_name(self):
try: