Skip to content

Instantly share code, notes, and snippets.

View galElmalah's full-sized avatar

Gal Elmalah galElmalah

View GitHub Profile
@galElmalah
galElmalah / aoc-day-3.go
Created December 7, 2022 06:27
Advent of Code 2022 solution in Go
package main
import (
"fmt"
"os"
"strings"
)
func check(e error) {
if e != nil {
@galElmalah
galElmalah / aoc-day-4.go
Created December 5, 2022 09:09
Advent of Code 2022 day 4 solution in Go
package main
import (
"fmt"
"os"
"regexp"
"strconv"
"strings"
)
@galElmalah
galElmalah / aoc-day-2.go
Created December 4, 2022 15:29
a Go solution for AoC day 2 question
package main
import (
"fmt"
"os"
"strings"
)
func check(e error) {
if e != nil {
@galElmalah
galElmalah / aoc-day-1.go
Created December 4, 2022 11:35
Advent of Code 2022 - Day 1 Solution in Go
package main
import (
"fmt"
"os"
"sort"
"strconv"
"strings"
)
const axios = require('axios')
const fs = require('fs')
const jobs = []
for (let index = 0; index < 40; index++) {
jobs.push('https://static.parastorage.com/services/promote-seo/1.2335.0/business-manager-component.bundle.min.js')
}
console.log('running ',+jobs.length, ' jobs')
console.time('download and write')
Promise.all(jobs.map((url, i) => axios.get(url).then(({data}) => {
@galElmalah
galElmalah / jobs.ts
Created October 22, 2021 08:01
pseudo code
interface Job {
path: string,
try: number // intially 0
}
const pool = someWorkersPoolLibrary()
const Q = downloadAllRules()
while(Q.length || pool.pendingJobs) {
const currentJob = Q.unshift()
const cases = require('./cases');
const caseRunner = require('../../utils/caseRunner');
const parse = (input) => {
return input
.split('\n')
.filter(Boolean)
.map((r) => r.split(''));
};
const id = ({ i, j }) => `${i},${j}`;
const parse = (input) => {
return input.split('\n').map((row) => row.split(''));
};
const getNeighbors = (maze, i, j) => {
const di = [-1, 0, 1, 0];
const dj = [0, 1, 0, -1];
const ns = [];
type MatrixFn = (
cell?: any,
{ y, x }?: { y: number; x: number },
matrix?: any[][]
) => any;
export const Matrix = (matrix: any[][]) => {
return {
forEach(fn: MatrixFn) {
matrix.forEach((_, row) => {
bubbleSort(randomArray, (action) => {
actionsMap[action.type](action, arrayMembers);
ctx.clearRect(0, 0, innerWidth, innerHeight);
drawAll();
});