Skip to content

Instantly share code, notes, and snippets.

View martian17's full-sized avatar
🛰️
Working from home

Yutaro Yoshii martian17

🛰️
Working from home
View GitHub Profile
@martian17
martian17 / parking-spot.md
Last active March 14, 2023 09:56
Parking Jam Solver

Get all cars out!

This problem is based on a famous mobile game called parking jam. Here is a video footage from the game play.
https://www.youtube.com/watch?v=cDv_-LezHPw
In order to define the rules better, I decided to change it up a bit. Cars, walls, and empty spaces are now represented by characters on a grid of string. Each car consists of an arrow spanning two adjacent squares with the charset <>v^|-. Walls are marked by *, and the exit is marked by =. Here is an example input:

********
*<-|->^*
*  v<-|*
*<-  | =
* |-&gt;v *
@martian17
martian17 / hanoi.js
Created March 14, 2023 15:08
Solves tower of hanoi
const range = function(n){
const arr = [];
for(let i = 0; i < n; i++){
arr.push(i);
}
return arr;
};
const peek = function(arr){
return arr[arr.length-1];
@martian17
martian17 / intersection.ts
Last active March 18, 2023 23:37
Testing code from stackoverflow
// source: https://stackoverflow.com/questions/72669756/property-selected-of-type-boolean-is-not-assignable-to-string-index-type
interface Field {
selected: boolean;
value: any;
}
type ConflictingVersionModel = {
[key: string]: Field;
} & { selected: boolean };
@martian17
martian17 / index.ts
Created March 23, 2023 14:38
meta programming in ts
//util functions
const isNode = typeof window === "undefined";
const U8FromView = function(view: ArrayBufferView): Uint8Array{
if(view instanceof Uint8Array){
return view;
}
return new Uint8Array(view.buffer,view.byteOffset,view.byteLength);
};