Activity for Hakerh400
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Answer | — |
A: Run-length encode a byte sequence JavaScript (Node.js), 146 bytes f=(a,c=n=(b=d=[],e=x=>x&&(c>191|d>2?b.push(d+192,c):b.push(...d+n?[c,c]:[c]),c=n,d=0)))=>(a.map(b=>c^n?c=(e(d>62|b-c),d++,b):(c=b,d=1)),e(c-n),b) Try it online! Ungolfed version (more) |
— | over 2 years ago |
Answer | — |
A: Find good coalitions [Haskell], 141 bytes import Control.Monad f a=map(map fst)$filter(\c->let{g=map snd;e=sum(g a)`div`2;f=g c;d=sum f}in d>e&&all((<=e).(d-))f)$filterM(pure[1<0..])a Try it online! Explanation: we generate all possible coalitions and then filter out the bad ones. `filterM... (more) |
— | over 2 years ago |
Answer | — |
A: Encode and decode floating point integers [Haskell], 219 194 bytes h!n=x n?(a?c$d>n&&(even a?f(x)[0..] (a?b)c|c=a|0<1=b Try it online! Depending on the first argument: False - Encode True - Decode (more) |
— | over 2 years ago |
Answer | — |
A: Reverse your quine JavaScript (Node.js), 60 bytes f=a=>console.log(`)(f;${[...f+``].reverse``.join``}=f`);f() Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Reverse your quine [Haskell], 78 bytes main=putStr$reverse$a++show a where a="main=putStr$reverse$a++show a where a=" Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: The Ludic Numbers [Haskell], 51 49 bytes -2 bytes thanks to Wheat Wizard 1:g[2..] g(a:b)=a:g[d|(c,d)0] Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Collatz conjecture; Count the tries to reach $1$ [Haskell], 43 39 bytes f 1=0 f n=1+f([div n 2,n3+1]!!mod n 2) Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Decode periodic decimal fractions [Haskell], 352 bytes f a=let{(d,e)=y$filter(>'-')a;f=drop 1e;g=0!h;h=fst n;i=scanr(:)[]h;(j,k)=elem '.'f%(1!head(filter(\a->a>[]&&elem(a++a)i)i++[[last$'0':h]]));(l,m)=(read('0':d)::Integer,1)#g#(j,ksnd g);n=y f}in(last$l:[-l|elem '-'a],m) y=break([])%(read b,10^length b-a) (a,b)... (more) |
— | over 2 years ago |
Answer | — |
A: Abbreviate everything [Haskell], 139 138 bytes import Data.Char f(a:b)|d a=toUpper a:f(dropWhile(\a->e a"-'"||d a)b)|e a":;"=a:c|e a".?!"=' ':c|0<1=c where c=f b;d=isLetter;e=elem f a=a Try it online! (more) |
— | over 2 years ago |
Article | — |
Play dominoes using strings Challenge Given two lists of strings $A$ and $B$, both of length $n\ge1$. For any $i\in\left\\\{1,\dots,n\right\\\}$, by $Ai$ and $Bi$ we represent the $i$-th string from $A$ and $B$, respectively. Associative infix binary operator $+$ represents string concatenation. Output any $k1,\dots,km$ f... (more) |
— | over 2 years ago |
Answer | — |
A: Expand a polynomial [Haskell], 45 bytes foldl(\a b->zipWith((-).(b))(0:a)$a++[0])[1] Try it online! Uses the "highest power first" convention. Sometimes multiplies the polynomial by $(-1)$. (more) |
— | over 2 years ago |
Answer | — |
A: Repeat the characters [Haskell], 18 bytes (.replicate).(>>=) Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Digit Sum Integer Sequence (working title) [Haskell], 56 bytes f a=a:f(a+g(read.pureshow a)) g a=minimum a+maximum a Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: "Hello, {name}!" [Haskell], 43 35 bytes main=interact$("Hello, "++).(++"!") Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Stairs? Stairs! Stairs. [Haskell], 78 bytes (!)0.(2) i!n|i<n=(drop 3$(n-i)#' '++"/"++i#'#'):(i+2)!n|0<1=[] (#)=replicate Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: When The Ternary Is Balance [Haskell], 78 77 bytes (g[0]!) g a=mapM(\->[-1..1])a++g(0:a) (a:b)!c|foldl1((+).(3))a==c=a|0<1=b!c Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Generalized Sort [Haskell], 29 bytes import Data.List foldr sortBy Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Make my value binary [Haskell], 29 bytes import Text.Printf printf"%b" Try it online! Without builtins: [Haskell], 37 bytes f n|n<2=[n]|0<1=f(div n 2)++[rem n 2] Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Compute the determinant [Haskell], 75 73 bytes -2 bytes thanks to @user f[]=1 f(x:y)=foldr(-)0$zipWith(\i->(f[take i r++drop(i+1)r|r<-y]))[0..]x Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Multiply two strings [Haskell], 25 bytes f a=(>>= \c->map(min c)a) Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Are All Elements Equal? [brainfuck], 40 bytes Outputs `ÿ` if all elements are equal, and `\x00` byte otherwise. ->,>,[[->+]>>[->]>[->]>>][[-]-.+] Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Are All Elements Equal? [Haskell], 16 bytes f(a:b)=all(==a)b Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Reduce over the range [1..n] [Haskell], 18 bytes n!g=foldl1 g[1..n] Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Guess the language! (Cops' Thread) ???, 268 bytes !(115,114,101,98,98,111,82,32,100,110,97,32,115,112,111,67)0|2.(0,0). 1|0|5.#.(0,1).(0,2)0|4.#.(2,0,(0,5),(0,2)).(0,1)-{0|5.#.(0,0 ,(0,1))(0,0,(0,1)).#.(0,(0,0,2))(0,(0,0,2)).#.(0,0,5)0|0|1+0|2 .1|0|5.#.(0,1).(0,2)0|4.#.(2,0,(0,5),(0,2)).(0,1)} New lines added ... (more) |
— | over 2 years ago |
Answer | — |
A: 99 Shortened Bottles of Beer [Haskell], 221 215 bytes f=a 99 (#)=(++) a n=d n#", "#c".\n"n#b(n-1) b 0="Go to the store and buy some more, "#d 99#"." b n="Take one down and pass it around, "#d n#".\n\n"#a n c m n=show n#" bottle"#['s'|n>1]#" of beer"#m d=c" on the wall" Try it online! ... (more) |
— | over 2 years ago |
Answer | — |
A: It's Hip to be Square [Haskell], 24 bytes Probably the optimal solution. Credits go to nimi from PPCG. f n=elem n$map(^2)[0..n] Try it online! My original solution, 25 bytes f a=any((==a).(^2))[0..a] Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: Guess the language! (Robbers' Thread) Cracks Shaggy's answer Let the cops be "Cops" The conjunction is " and " The robbers are "Robbers" Say the cops with the conjunction with the robbers It can be one of: FALSE Phooey Rotor The Shaggy's intended solution turns out to be Rockstar (found by @Razet... (more) |
— | over 2 years ago |
Answer | — |
A: Gamer Meme Creator [Haskell], 116 bytes a#b=a!b:a++[a!"BOTTOM TEXT"] a!b=replicate(div(m a-k b)2)' '++b m=foldr1 max.map k k=length.dropWhile(==' ').reverse Try it online! (more) |
— | over 2 years ago |
Answer | — |
A: A number adder, not a death adder [Haskell], 64 bytes main=do a>=print.("++a++"+).read" Try it online! Run both programs (more) |
— | almost 3 years ago |
Answer | — |
A: Word Set Square [Haskell], 110 bytes ```haskell f a=s>>=(#)$a++reverse a c@(a:b)!f=f c:b!f !=[] f#n=n!((n!).f) s(p:q)(d:e)(b:c)|e==c||e==[]=b|q==c=d|0<1=' ' ``` Try it online! (more) |
— | about 3 years ago |
Answer | — |
A: Is it a near-anagram? [JavaScript (Node.js)], 150 71 bytes f=(a,b)=>a[b.length]?f(b,a):b.filter(x=>a[y=a.indexOf(x)]=!y).length-1 Try it online! (more) |
— | about 3 years ago |
Answer | — |
A: The Pell Numbers [Haskell], 21 bytes f=0:scanl((+).(2))1f Try it online! (more) |
— | about 3 years ago |
Answer | — |
A: Win a War (or at least a few battles) JavaScript, 227 bytes (n,k,A,C=(a,b)=>a?[...C(--a,b),b(a)]:[],f=m=>m?C(n+1,i=>f(m-1).map(([p,s])=> [[...p,i],s+i])).flat():[[[],0]])=>f(k).map(([b,s])=>a=s-n?a:b.map((a,b)=>(q =A[b])(229 bytes, because TIO uses an old version of Node.js that has a parsing issue when an arrow func... (more) |
— | about 3 years ago |
Answer | — |
A: Solve Goldbach's Conjecture [JavaScript (Node.js)], 87 bytes f=(a,b=2,c=a-b,d=(a,b=2)=>bd(++a)?a:e(a))=>d(c)?[b,c]:f(a,e(b)) Try it online! (more) |
— | about 3 years ago |
Answer | — |
A: Create an Alphabet Diamond [JavaScript (Node.js)], 78 bytes (m=(a,b=26,c=a(--b))=>b?[c,...m(a,b),c]:[c])=>m(a=>m(b=>(c=25-a-b)<0?32:c+65)) Try it online! (more) |
— | about 3 years ago |
Answer | — |
A: Longest parallel lines [JavaScript (Node.js)], 541 540 bytes for(='=>)==!(+==0h,.map(M,R(=1,,e,b	&&Nl=[-1,))s(n,=(a	a=u,v(i=g(z,u,f=(a,w,cs=Math.ma... (more) |
— | about 3 years ago |
Answer | — |
A: Write a Deadfish Interpreter [JavaScript (Node.js)], 80 bytes f=a=>a.map(a=>(a&=6,a-2?a-6?c+=1-a/2:d+=c+' ':c=c,c=c!=-1&c!=256),c=0,d='')&&d Try it online! (more) |
— | about 3 years ago |
Answer | — |
A: Truthify an array [JavaScript (Node.js)], 74 70 bytes Works for any number of dimensions. f=(a,z=[])=>a.map?.((b,c)=>z.push(...f(b).map(a=>[c,...a])))?z:a?[z]:z Try it online! (TIO uses an old version of Node.js that does not support the `?.` operator, but you can try the 74 bytes solution) (more) |
— | over 3 years ago |
Answer | — |
A: Golf me a polygonal loader JavaScript (Browser), 670 bytes ```js for(="=1,w=):=0,w(=f(||(.join`w?q-w?q=-w(a,b=>A(L5,a),g.innerText=N=L=D=T,I=,c,d)a-d?I,b(d,cd+1c,A=)I(a,(x,y)[...y,b(x)],[](U=(Kf=({value:a})a==[a|]+[]&&aKQnFlZdOtQ-N|F-L|Z-D|O-T&&(B=Q,e=F,H=Z,V=O,K&=(V>0&V1&e0&H<=B(e-1)K&&(N=Q,L=F,D=Z,T=O,X=N-4&&L,Y,WE=N==3,... (more) |
— | over 3 years ago |
Answer | — |
A: Towering Cistercian Representation [JavaScript (Node.js)], 606 bytes for(="=>\\\\  =j(...(a:').join`\\n`q,/ / /	d[c[) .match(/.{.||]/g,=='.mapf=(n,m... (more) |
— | over 3 years ago |
Article | — |
Bijection between natural numbers and finite sets Definitions A natural number is either zero, or a successor of some other natural number. A set is an unordered collection of zero or more elements. Each element is a set. Two sets that have same elements are equal. In this challenge we consider only hereditarily finite sets. Cardinality of ... (more) |
— | over 3 years ago |
Answer | — |
A: Integer to Roman numeral [JavaScript (Node.js)], 147 bytes f=(a,b='IVXLCDM',g=Math.log10(a)b[g].repeat(a))=>a?(e<4?j(e):e<6?j(5-e)+i:e<9?i+j(e-5):j(1)+b[g+2])+f(a%c):'' Try it online! (more) |
— | over 3 years ago |
Answer | — |
A: Generate Lewis Caroll's Jabberwocky [Bubblegum], 769 bytes 074cd1dc7fb6baed2f568915ffeb6aa5c775264a9a6f77eb418f0793da59b234599dadb6804269dbb5a213a05c807b0723f79512c284f46e8dbb6b0274f1b36606988b67ea58cf68beabe10f158702fcbf4c2b30d7b4f26190901aa713e125aee132d76940aff74588831a1908d8541c09f042556a7c7e24e80370734855cd398797d016c22627e... (more) |
— | over 3 years ago |
Answer | — |
A: Output 256 in many different ways JavaScript, 11 solutions !``>>1111 TIO 4444444&444444444444&444444444444444&44444444444444444 TIO 3^7^73^333 TIO (6666666|66666666666|666666666666666|666666666666666666666666666666) TIO (more) |
— | over 3 years ago |
Answer | — |
A: Reverse an ASCII string JavaScript, 25 24 bytes -1 byte thanks to @Arnauld f=([a,...b])=>a?f(b)+a:b Try it online! (more) |
— | over 3 years ago |
Question | — |
Given the preorder and the inorder of a tree, output the postorder Definitions A binary tree is either a `null` (leaf), or an object (node). A node contains a value (non-negative integer) and two pointers (left and right) to two separate binary trees. A binary tree can be traversed in many different ways. Here we define preorder, inorder and postorder. We defi... (more) |
— | over 3 years ago |
Answer | — |
A: Prime Difference [JavaScript (Node.js)], 86 bytes f=(a,b=2,c=(a,b=2)=>a-b?a%b&&c(a,b+1):1,d=a=>c(++a)?a:d(a))=>!c(b)|d(b)-b<a?f(a,b+1):b Try it online! (more) |
— | over 3 years ago |
Answer | — |
A: Longest Increasing Subsequence [JavaScript (Node.js)], 70 56 bytes f=([a,...b],c=f)=>1/a?Math.max(f(b,c),[a]>c&&1+f(b,a)):0 Try it online! (more) |
— | over 3 years ago |
Article | — |
Given the preorder and the inorder of a tree, output the postorder [FINALIZED] Definitions A binary tree is either a `null` (leaf), or an object (node). A node contains a value (non-negative integer) and two pointers (left and right) to two separate binary trees. A binary tree can be traversed in many different ways. Here we define preorder, inorder and postorder. We defi... (more) |
— | over 3 years ago |
Answer | — |
A: Shape of an array [JavaScript (Node.js)], 36 bytes f=a=>a?.map?[a.length,...f(a[0])]:[] Try it online! (more) |
— | over 3 years ago |