Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / longestNiceSubstring.js
Created August 13, 2023 18:56
Longest Nice Substring containing uppercase and lowercase matching letters https://leetcode.com/problems/longest-nice-substring
const longestNiceSubstring = s => {
// Brute-force.
let result = '';
let max = 0;
const adder = 32; // uppercase or lowercase compliment
// Begin building the word from the left and appending 1 character at a time.
for (let i=0; i<s.length-1; i++) {
const hash = {};
let word = s[i];
@primaryobjects
primaryobjects / quiz3.txt
Last active August 4, 2023 02:09
IBM Introduction to Artificial Intelligence, Quiz 3, https://www.coursera.org/learn/introduction-to-ai
QUESTION 1/10
What is Al ethics?
1 point
I How and why an Al system arrived at a particular outcome or recommendation
An organization's act of governing Al through its corporate instructions, staff, processes, and systems
** A multidisciplinary field that investigates how to maximize Al's beneficial impacts while reducing risks and adverse impacts
How to build and use Al in ways that align with human ethics and expectations
QUESTION 2/10
In Al, what is fairness?
@primaryobjects
primaryobjects / quiz2.txt
Created August 4, 2023 01:58
IBM Introduction to Artificial Intelligence, Quiz 2, https://www.coursera.org/learn/introduction-to-ai
QUESTION 1/10
Which of these statements is true?
1 point
) Cognitive systems can only process neatly organized structured data
Cognitive systems can only translate small volumes of audio data into their literal text translations at massive speeds
Cognitive systems can derive mathematically precise answers following a rigid decision tree approach
** Cognitive systems can learn from their successes and failures
QUESTION 2/10
Which of these statements is true?
@primaryobjects
primaryobjects / quiz1.txt
Last active August 4, 2023 19:40
IBM Introduction to Artificial Intelligence, Quiz 1, https://www.coursera.org/learn/introduction-to-ai
Which of the following is NOT a good way to define Al?
1 point
) Al is Augmented Intelligence and is not intended to replace human intelligence rather extend human capabilities
Al is the use of algorithms that enable computers to find patterns without humans having to hard code them manually
I Al is the application of computing to solve problems in an intelligent way using algorithms.
** Al is all about machines replacing human
Which of the following is an attribute of Strong or
Generalized Al?
1 point
const plusOne = digits => {
// Set the index to the last digit.
let i = digits.length - 1;
// If the index digit < 9, increment it and return answer.
if (digits[i] < 9) {
digits[i]++;
return digits;
}
else {
@primaryobjects
primaryobjects / document-search.ipynb
Created July 29, 2023 22:28
Building a web page search engine using NLP and ChatGPT
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@primaryobjects
primaryobjects / launch.json
Last active July 17, 2023 19:52
VSCode launch.json for Perl. Download https://strawberryperl.com and install Perl Debugger in VSCode https://marketplace.visualstudio.com/items?itemName=bscan.perlnavigator
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "perl",
"request": "launch",
"name": "Perl Debug",
const eraseOverlapIntervals1 = intervals => {
let count = 0;
const hash = {};
// Sort intervals by their ending time ascending.
intervals.sort((a, b) => {
return a[1] - b[1];
});
// Build a list of all occupied slots.
@primaryobjects
primaryobjects / data.py
Last active July 10, 2025 21:16
LLM ChatGPT prompt engineering accuracy statistics. Using F-score and accuracy to measure effectiveness of prompts for classification. https://learn.deeplearning.ai/chatgpt-prompt-eng/lesson/1/introduction
messages = [
{'content': 'I hate this food.', 'truth': 1},
{'content': 'This movie is terrible.', 'truth': 1},
{'content': 'I really like this play.', 'truth': 0},
{'content': 'I am just not sure.', 'truth': 0},
{'content': 'I can\'t believe you would do something like that!', 'truth': 1},
{'content': 'This is absolutely unacceptable!', 'truth': 1},
{'content': 'I am so angry right now, I can\'t even think straight.', 'truth': 1},
{'content': 'How could you be so thoughtless?', 'truth': 1},
{'content': 'You have no idea how much you\'ve hurt me.', 'truth': 1},
function birthday1(s, d, m) {
// Naive approach, O(n^2)
let count = 0;
if (s && s.length) {
for (let i=0; i<s.length - m + 1; i++) {
// Find all contiguous groups of m-length from this point.
let sum = 0;
for (let j=i; j<i+m; j++) {