Skip to content

Instantly share code, notes, and snippets.

@somebody1234
somebody1234 / code.js
Last active August 28, 2016 01:33
TNB missing XKCDs
a=[];i=1;handle=setInterval(_=>{$.get(`/search?q=xkcd.com&Room=240&page=${i++}&pagesize=100&sort=newest`,data=>data.match(/xkcd.com\/\d+/g).map(s=>a.push(+/\d+$/.exec(s)[0])));if(i===12){clearInterval(handle);b=[];for(j=1;j<1726;j++)if(!a.includes(j))b.push(j);}},3000)
@somebody1234
somebody1234 / encodeInput.js
Last active October 24, 2016 08:07
TIO modified snippet
function encodeInput(encoding) {
var input = document.getElementById("input");
return input ? "&input=" + encoding(input.value) : "";
}
Enter numeric array: [1,2,[],[3,4,5]]
Array
├1
├2
├Array
└Array
├3
├4
└5
#!/usr/bin/python3
import http.server
N=25001
numbers = ["()" * i for i in range(N)]
def tryi(n, s):
if n < N and len(numbers[n]) > len(s):
numbers[n] = s
//note: requires minimist (npm i minimist)
'use strict';
const {accessSync, mkdirSync, unlinkSync, readFileSync, writeFileSync, F_OK} = require('fs'),
name = 'hpm',
{join} = require('path'),
homeDir = require('os').homedir(),
dir = join(homeDir, '.' + name),
path = join(homeDir, '.hyper.js'),
2 1
3 2
4 4
5 6
6 8
7 14
8 18
9 27
10 36
11 52
@somebody1234
somebody1234 / 32
Created August 6, 2017 04:04
Count arrays of periods
(1, 1, 1, 1, 1)
(1, 1, 1, 1, 32)
(1, 1, 1, 1, 31)
(1, 1, 1, 1, 30)
(1, 1, 1, 1, 29)
(1, 1, 1, 1, 28)
(1, 1, 1, 1, 27)
(1, 1, 1, 1, 26)
(1, 1, 1, 1, 25)
(1, 1, 1, 1, 24)
@somebody1234
somebody1234 / 32
Created August 6, 2017 04:04
Count arrays of periods
(1, 1, 1, 1, 1)
(1, 1, 1, 1, 32)
(1, 1, 1, 1, 31)
(1, 1, 1, 1, 30)
(1, 1, 1, 1, 29)
(1, 1, 1, 1, 28)
(1, 1, 1, 1, 27)
(1, 1, 1, 1, 26)
(1, 1, 1, 1, 25)
(1, 1, 1, 1, 24)
bin(): n leading 1s trailing 0s
1 1 0
10 1 1
11 1 0
100 10 1
101 1 10
110 11 1
111 1 0
1000 11 1
1001 10 10
{
"type":"methods",
"title":"Array Methods",
"object":"A",
"intro":[],
"methods":{
"a(s/n)":{
"description":"Returns the last index of `x`s/n`` in `A`, or `-1` if not found.",
"returns":"N",
"version":"1.4.5",