This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const keySequence = ['l','o','l']; | |
let userInput = new Array( keySequence.length ); | |
window.addEventListener( 'keydown', ( { key } ) => { | |
userInput = [ ...userInput.slice( 1 ), key ]; | |
if ( keySequence.every( ( v, k ) => v === userInput[ k ] ) ) { | |
alert( 'Yatta!' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#define COMPUTATIONS 100000 | |
int c,G,o,d,S,k,i,L,l; | |
int main(int n,char **v){for(!(n=v?0:n)?srand(c=time(NULL)),printf("Current time is %d\n\n",c),k=L=0:n<0||(S=0);i!=COMPUTATIONS?1:(printf("\nFound %.2f%% Smith numbers\n",(double)L*100/COMPUTATIONS),0);!n?d=2,G=4,main(o=l=((rand()%32768)+1)*((rand()%32768)+1)+1,NULL)?printf("%10d is a Smithnumber\n",l,L++):0,i++:(n<0||!(n%d)?k=d,main(-1,NULL),n/=d:(d+=d<5?d-1:(G=6-G))))if(!n?0:(d*d>n))return n<0?!k||(!(n+1)?S-=k%10:(S+=k%10),k/=10,main(n,NULL)):(S&&n-1?k=n,main(-1,NULL),k=o,main(-1337,NULL),!S:0);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+++++[>++[>+>+ ++>++++>++++>++++>++++++ | |
>++++++>+++++++ ++>+++++++++<<<<<<<<<-]>> | |
>+>+>+> >>>+[<]< -]>> >++>-->>+>>++>+ | |
>--<<<< <<<..... .> ....<...... | |
...>... <<.>.... >.>>>>>.<. | |
<<<<.. ..<.... >..>>>>>.< | |
.<<<<. >>>.<<. >>>>>.<.< | |
<<<<< <.>...> >>>.>>>. | |
<<<.< <<<..>> .>>>>>.< | |
<.<<< <<...>> >>>.<<< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* trollsort - sorts an array of n integers - (the troll way) Kappa Keepo | |
* ---------------------------------------------------------------------- | |
* just some code i wrote for fun. i think complexity should be same with | |
* bubblesort O(n^2) altho im not sure. feel free to explore it yourself. | |
* obviously its easy to break it but runs ok for most cases. | |
* qs O(nlogn) coming soon... | |
* qs is now ready | |
* ---------------------------------------------------------------------- | |
* WARNING!!! the is a million undefined behavior things in this code plz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.assign(Date, { | |
emojiclocks: [11,...Array(23).keys()].map(c=>String.fromCodePoint(128336+c%12)) | |
}, { | |
dayperiods: ` ${['',... | |
'evening afternoon morning night' | |
.split(/ /)].copyWithin(0,4).join(' ')} ` | |
.replace(/\w+ /g, (w, i) => w.repeat(i / 7 + 3)) | |
.match(/\w+/g) | |
.reverse() | |
.slice(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
copy.sh/brainfuck | |
this | bf | bf | bf | |
++[------>+<]>..++[->++<]>+.-[-->+<]>......---[-->+++<]>-.+[--->++<]>+.+[----->+<]>.++[-->+++<]>.[--->++<]>.[->+++++++++<]>.---..++[->++<]>+.-[-->+<]>.---[-->+++<]>-.+[--->++<]>+..+[----->+<]>.++[-->+++<]>.[--->++<]>.+[--->++<]>+.+++.-.[->++<]>+.-[-->+<]>..---[-->+++<]>-.+[--->++<]>+.+[----->+<]>.++[-->+++<]>.[--->++<]>.[->+++++++++<]>.......-...[->++<]>+.-[-->+<]>..---[-->+++<]>-.+[--->++<]>+...+[----->+<]>.++[-->+++<]>.[--->++<]>.--[---->+++<]>.+.---.++[->++<]>+.-[-->+<]>...---[-->+++<]>-.+[--->++<]>+..+[----->+<]>.++[-->+++<]>.[--->++<]>.+[--->++<]>+.+++..---.++[->++<]>+.-[-->+<]>.....---[-->+++<]>-.+[--->++<]>+.+[----->+<]>.++[-->+++<]>.[--->++<]>.[->+++++++++<]>.---..++[->++<]>+.-[-->+<]>..---[-->+++<]>-.+[--->++<]>+...+[----->+<]>.++[-->+++<]>.[--->++<]>.[->+++++++++<]>.[->++<]>-.-[-->+<]>...---[-->+++<]>-.+[--->++<]>+..+[----->+<]>.++[-->+++<]>.[--->++<]>.[->+++++++++<]>.-..[->++<]>+.-[-->+<]>....---[-->+++<]>-.+[--->++<]>+...+[----->+<]>.++[-->+++<]>.[--->++<] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// shortest BF interpreter with whitespace: | |
s[999], *r=s, *d, c; | |
main(a, b) | |
{ | |
char *v=1[d=b]; | |
for(;c = *v++ % 93;) | |
for(b = c%7 ? | |
a && |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fmb = F**K My Brain | |
// ins = instructions string | |
// oup = terminal output callback function | |
// inp = terminal input callback function | |
function fmb(ins, oup, inp) { | |
var m = [], dp = 0, ip = 0, | |
il = ins.length, scp = {}, | |
op, mdp; | |
for(; ip < il; ip++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.hasOwnProperty('shuffle') || Object.defineProperty(Array.prototype, 'shuffle', { | |
value: function() { return this.sort(() => Math.random() - .5); } | |
}); | |
let deck = [...'♠♣♥♦'].flatMap(s => ('A,'+[...Array(11).keys()].slice(2)+',J,Q,K').split(/,/).map(c => c + s)); | |
console.log(deck); | |
console.log(deck.shuffle()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void quicksort(int l, int u) { | |
int i, m; | |
if (l >= u) return; | |
m = l; | |
for (i = l+1; i <= u; i++) | |
if (x[i] < x[l]) | |
swap(++m, i); | |
swap(l, m); | |
quicksort(l, m-1); | |
quicksort(m+1, u); |
OlderNewer