…or create a new repository on the command line
echo "# test222" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/nickforce/test222.git
git push -u origin main
| public with sharing class day01 { | |
| public static Map<String,String> numberMap = new Map<String,String>{ | |
| 'one' => '1', | |
| 'two' => '2', | |
| 'three' => '3', | |
| 'four' => '4', | |
| 'five' => '5', | |
| 'six' => '6', | |
| 'seven' => '7', | |
| 'eight' => '8', |
| public with sharing class Advent { | |
| @AuraEnabled | |
| public static Integer readPuzzleInput(String fileName, String fileContent) { | |
| return read_lines(fileContent); | |
| } | |
| public static Integer read_lines(String puzzleInput) { | |
| // Split by newline chars | |
| List<String> lines = puzzleInput.split('\n'); | |
| // call puzzle solution |
| import { LightningElement } from 'lwc'; | |
| import readPuzzleInput from '@salesforce/apex/Advent.readPuzzleInput'; | |
| export default class AdventofCode_FileReader extends LightningElement { | |
| puzzleInput; | |
| puzzleInputFileName; | |
| puzzleAnswer; | |
| handlePuzzleInputChange(event) { | |
| this.puzzleInput = event.target.files[0]; |
| <template> | |
| <lightning-card title="Puzzle File Reader"> | |
| <div class="slds-p-around_medium"> | |
| <lightning-input type="file" label="Select File" onchange={handlePuzzleInputChange}></lightning-input> | |
| {puzzleInputFileName} | |
| <div class="slds-p-top_small"> | |
| <lightning-button label="Read Puzzle Input" onclick={uploadPuzzleInput} disabled={disabled}></lightning-button> | |
| </div> | |
| </div> | |
| </lightning-card> |
…or create a new repository on the command line
echo "# test222" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/nickforce/test222.git
git push -u origin main
| import * as fs from 'fs'; | |
| const elves = fs.readFileSync("day01.txt", { encoding: "utf-8" }) | |
| .replace(/\r/g, "") | |
| .trim() | |
| .split("\n\n"); // split on newline | |
| function findTop3CalorieElves() { | |
| const calories = elves.map((elf) => { | |
| const calories = elf.split("\n").map(Number); |
| import * as fs from 'fs'; | |
| const elves = fs.readFileSync("day01.txt", { encoding: "utf-8" }) | |
| .replace(/\r/g, "") | |
| .trim() | |
| .split("\n\n"); // split on newline | |
| function findMaxCaroliesElve() { | |
| const calories = elves.map((elf) => { | |
| const calories = elf.split("\n").map(Number); |
| /** | |
| * @param {number} x | |
| * @return {boolean} | |
| */ | |
| var isPalindrome = function(x) { | |
| if(x < 0) return false; | |
| if(x == 0) return true; | |
| if(x.toFixed(0).split('').reverse().join('')-0 == x) return true; | |
| return false; | |
| }; |
| Array.prototype.last = function() { | |
| if(!this?.length) return -1; | |
| return this.pop(); | |
| }; | |
| /** | |
| * const arr = [1, 2, 3]; | |
| * arr.last(); // 3 | |
| */ |
| /** | |
| * @param {number[]} nums | |
| * @param {number} target | |
| * @return {number[]} | |
| */ | |
| var twoSum = function(nums, target) { | |
| let numObj = {} | |
| for(i = 0; i < nums.length; i++) { | |
| let other = target - nums[i]; | |
| if(numObj[other] !== undefined) { |