Skip to content

Instantly share code, notes, and snippets.

View cloverich's full-sized avatar
🏠
Working from home

chris cloverich

🏠
Working from home
View GitHub Profile
import fs from "fs";
const lines = fs.readFileSync("./data.csv", "utf8").split("\n");
let idx = 0;
const asRecords: Array<Record<string, any>> = [];
while (lines.length) {
const line = lines.pop();
const [colId, colProp, colVal] = line!.split(",");
@cloverich
cloverich / subsequence.js
Created October 12, 2020 19:57
Subsequence problem. I solved this problem while in a meeting, trying to understand how difficult it would be.
function isSubsequence(s: string, t: string): boolean {
let aIdx = 0;
let bIdx = 0;
while ((aIdx < s.length) && (bIdx < t.length)) {
const aChar = s.charAt(aIdx);
const bChar = t.charAt(bIdx);
if (aChar === bChar) {
aIdx++;
}
// console.log can be used to print information to the screen
console.log("Hello, World"); // prints "Hello, World"
// Create an object `foodItem` to hold some information
var foodItem = {
fat: 25,
carbs: 82
}
// fat and carbs are now stored insode of foodItem