Skip to content

Instantly share code, notes, and snippets.

View JoshuaPaulBarnard's full-sized avatar
:atom:

Joshua Paul Barnard JoshuaPaulBarnard

:atom:
View GitHub Profile
@JoshuaPaulBarnard
JoshuaPaulBarnard / create_staircase.py
Last active March 14, 2024 04:41
Create Staircase
# A staircase is a list of lists where list 0 has length 1, and every list i+1 is one item longer than list i.
def create_staircase(integers):
integers.sort(reverse=True) # Sort the integers in descending order
staircase = [] # Initialize the staircase as an empty list
while len(integers) != 0 : # Continue until the list of integers is empty
sublist_length = len(staircase) + 1 # Determine the length of the next sublist
sublist = integers[:sublist_length] # Extract integers for the next sublist
@JoshuaPaulBarnard
JoshuaPaulBarnard / leet-speak-converter.py
Last active January 30, 2024 04:10
1337 Speak Converter
# 1337 Speak Converter
# Author: Joshua Paul Barnard
# Date: January 29th, 2024
# This is my 1337 speak converter. There are many like it, but this one is mine.
# There are many different ways to use 1337 speak, and some letters can have tens of variations.
# So I created this converter to be able to quickly convert text into my style of 1337.
# Function to replace characters
@JoshuaPaulBarnard
JoshuaPaulBarnard / a==1&&a==2&&a==3.js
Created May 26, 2023 04:07
Question: Can (a==1 && a==2 && a==3) ever evaluate to 'true' in JavaScript?
let b = 1;
Object.defineProperty(globalThis,'a',{
get(){return b++;}
});
let result = Boolean( 'false' )
if (a == 1 && a == 2 && a == 3) {
result = 'true'
console.log( result );
@JoshuaPaulBarnard
JoshuaPaulBarnard / factors.cpp
Created December 16, 2022 06:47
Factors of a number
//-----------------------------------------------------
// Program returns the factors for an inputted number.
// filename: factors.cpp by Joshua Paul Barnard
//-----------------------------------------------------
#include<iostream>
using namespace std;
int main()
{
@JoshuaPaulBarnard
JoshuaPaulBarnard / allmax.py
Created May 19, 2021 12:02
Get the position of all the max values
def allmax_positions( input_array ):
if len(input_array) == 0:
return []
positions_of_max_values = [0]
the_max_values = input_array[0]
for counter_i in range(1, len(input_array)):
if input_array[counter_i] > the_max_values:
positions_of_max_values = [counter_i]
the_max_values = input_array[counter_i]