Skip to content

Instantly share code, notes, and snippets.

@Gerst20051
Gerst20051 / PalindromeCreator.js
Last active September 8, 2021 10:48
Palindrome Creator
function PalindromeCreator(str) {
const isStringPalindrome = isPalindrome(str);
if (isStringPalindrome) return 'palindrome';
const palindrome = findPalindrome([{
str,
chars: [],
}], 2, 0);
return palindrome && palindrome.str.length > 2 ? getRemovedCharsForPalindrome(palindrome) : 'not possible';
}
@Gerst20051
Gerst20051 / WordSplit.js
Last active August 24, 2021 19:47
Word Split
function WordSplit(strArr) {
const word = strArr[0];
const substrings = generateSubstrings(word);
const words = substrings.filter(substring => strArr[1].includes(substring));
const pairs = generatePairs(words);
const pair = pairs.find(pair => pair.join('') === word);
return pair ? pair.join(',') : 'no pair';
}
function generateSubstrings(str) {
@Gerst20051
Gerst20051 / How to Install JDK MacOS Homebrew.md
Created August 10, 2021 03:51 — forked from gwpantazes/How to Install JDK MacOS Homebrew.md
How to install different JDK versions on MacOS with Homebrew

How To Install Different JDK Versions on MacOS with Homebrew

Keywords: Java, JDK (Java Development Kit), MacOS, Homebrew, Specific Version

This how-to guide covers how to install different versions of the JDK on MacOS with Homebrew.

Table of Contents

@Gerst20051
Gerst20051 / slim-redux.js
Created July 1, 2021 00:35 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@Gerst20051
Gerst20051 / CrystalCollectors.js
Created October 18, 2018 21:58
CrystalCollectors
<!DOCTYPE html>
<html>
<head>
<title>CrystalCollectors</title>
<style>
.crystal-image {
cursor: pointer;
height: 100px;
margin: 10px;
width: 100px;
class NeuralNetwork:
def __init__(self, x, y):
self.input = x
self.weights1 = np.random.rand(self.input.shape[1],4)
self.weights2 = np.random.rand(4,1)
self.y = y
self.output = np.zeros(self.y.shape)
def feedforward(self):
self.layer1 = sigmoid(np.dot(self.input, self.weights1))
@Gerst20051
Gerst20051 / quiz3.py
Created February 27, 2019 22:58
Quiz 3 Python
num1 = int(raw_input("Please input first number: "))
num2 = int(raw_input("Please input second number: "))
def multiply():
print "{} multiplied by {} is {}".format(num1, num2, num1 * num2)
def divide():
print "{} divided by {} is {}".format(num1, num2, num1 / num2)
operator = raw_input("Would you like to multiply these numbers, or divide them? : ")
@Gerst20051
Gerst20051 / grow_gardens.js
Created October 12, 2020 19:54
Grow Gardens
// You are a botanist growing gardens of flowers for a picky customer. Your customer wants only red flowers but the seeds for your red flowers and your blue flowers have become mixed up. You are going to use all of your available gardens to grow flowers and then sell all of your red flowers to your customer.
// A few important points
// - Your soil quality is poor and successfully grown flowers will crowd out other seeds from growing easily. Thus the first seed you plant has a 75% chance of growing a flower but every subsequently planted seed only has a 25% chance of growing into a plant. Once a seed has failed to grow in a particular garden, you are going to abandon planting any additional seeds in it as it is an indication that the soil quailty is not conducive to growing any additional plants.
// - Red flowers are particularly competitive to neighboring plants. After a red flower grows in a garden, the garden will no longer be able to grow any additional plants and thus you will wholly abandon plan
@Gerst20051
Gerst20051 / language_dropdown.py
Last active June 24, 2021 04:51
Python 3 Language Dropdown
#--SETTINGS-IMPORTER------------------------
class SettingsImporter():
LANGUAGES = [
('ar', 'Arabic'),
('de', 'German'),
('el', 'Greek'),
('en', 'English'),
('es', 'Spanish'),
('fr', 'French'),
@Gerst20051
Gerst20051 / calc.js
Last active June 24, 2021 04:51
Calc JS Function
// TODO: finish
function calc(input) {
const characters = input.split(''); // ['(', '1', '+', '2', ')']
let depth = 0;
const operations = []; // ['1', '+', '2']
let calculation = [];
for (let characterIndex = 0; characterIndex < characters.length; characterIndex++) {
const character = characters[characterIndex];
if (character === '(') {