Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Posts by Moshi‭

75 posts
71%
+3 −0
Sandbox Add two negabinary integers [FINALIZED]

posted 3y ago by Moshi‭  ·  edited 11mo ago by trichoplax‭

71%
+3 −0
Challenges From the smallest seed

Challenge It's a bootstrapping challenge this time! Write a full program that, once run, writes the source code of another program that in turn, once run, writes the source code for another progra...

2 answers  ·  posted 2y ago by Moshi‭  ·  last activity 2y ago by orthoplex‭

71%
+3 −0
Challenges Can you give me half?

Python 3, 5 unique bytes, 28 total (()==())/((()==())+(()==())) (, ), =, /, + Uses (()==()) to get True with only 3 unique characters, as well as making the later grouping of (...+...) free. ...

posted 2y ago by Moshi‭

Answer
71%
+3 −0
Q&A Tips for golfing in Python

Use the unpacking * instead of list If you want to convert an iterator/generator into a list, use the * operator instead of using the list function, e.g. Instead of list(iterable) Use [*iter...

posted 2y ago by Moshi‭

Answer
71%
+3 −0
Challenges Collatz conjecture; Count the tries to reach $1$

Sclipting, (UTF-16) 44 34 32 bytes 貶要❶갠剩❷隔❸增갰乘嗎終并長貶 Because comparing with 1 is expensive (requires copying and decrementing), we instead use a modified version of the Collatz sequence - namely...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
71%
+3 −0
Challenges Generalized Sort

Challenge We all know and love the generic sort function, right? However, it only sorts based off one criterion - what if we want more? That's where you come in. Your task is to sort an array bas...

6 answers  ·  posted 2y ago by Moshi‭  ·  last activity 2y ago by radarek‭

Question code-golf sorting
71%
+3 −0
Challenges Ratio limits of fibonacci-like series

JavaScript (Node.js), 27 22 bytes -5 bytes thanks to Hakerh400‭ Direct computation f=n=>(n+(n*n+4)**.5)/2 $$\frac{n+\sqrt{n^2+4}}{2}$$ Try it online!

posted 3y ago by Moshi‭  ·  edited 3y ago by Moshi‭

Answer
71%
+3 −0
Challenges Multiply complex numbers.

JavaScript (Node.js), 99 96 69 bytes s=>([a,b,c,d]=s.match(/-?\d+/g),a*c-b*d+(a=a*d+b*c,a<0?'':'+')+a+'i') Try it online! This regex is probably the best way to get the numbers. Also, f...

posted 3y ago by Moshi‭  ·  edited 3y ago by Moshi‭

Answer
71%
+3 −0
Challenges Three Number Monte

MoshiBot from numpy.polynomial import Polynomial def MoshiBot(data, history): if len(history) < 10: return [180, 180, 0] lastmin = min(history[-1]) lastmid = sorted(history[-1])[1] ...

posted 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges The Ludic Numbers

Sclipting, (UTF-16) 58 52 bytes 가匱❸增平갠下氫終要鈮貶⓶梴감⓶上❸乘殲終終并鈮掘增 Gives the nth ludic number, 0-indexed. 가 Start list of Ludics with 0 匱❹增平갠下氫終 Create a list of numbers from 2 to n+1 squared 要 W...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges Reverse the bits in a Byte

Sclipting, (UTF-16) 26 bytes 갠긂갠밂乘감뒄뀢감雙갿및剩 Uses a formula I found here unsigned char b; // reverse this (8-bit) byte b = (b * 0x0202020202ULL & 0x010884422010ULL) % 1023;

posted 8mo ago by Moshi‭

Answer
66%
+2 −0
Challenges The holeyest base

Sclipting, (UTF-16) 86 bytes 標갠 관上가①要❶❹剩걉눑감⓶重右갰雙⓷加⓶❸分終⓷棄終并❶訂乾⓶折❷同終長괐縮⒈棄丟 Explanation: Input n 標 갠 관上 for b from 2 to 16 가 s = 0 ① n' = n 要 while n' is not 0 ❶❹剩 x = n...

posted 1y ago by Moshi‭  ·  edited 1y ago by Razetime‭

Answer
66%
+2 −0
Challenges Implement Rule 110

JavaScript (Node.js), 160 bytes (r,d,n,l=r.length,s=d.length,p=(n,i)=>n?"01110110"[4*p(--n,i-1)+2*p(n,i)+1*p(n,i+1)]:i>=0&i<s?d[i]:r[(i%l+l)%l])=>[...Array(4*l+s+2*n)].map((_,i)=...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges Run-length encode a byte sequence

JavaScript (Node.js), 101 82 bytes -19 bytes thanks to Shaggy! x=>x.replace(/(..)\1{0,62}/g,(c,g)=>c>'c'||c[5]?(192+c.length/2).toString(16)+g:c) Try it online! Everything can be sol...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges Convert integer to English

Python 3, 399 bytes def f(n): if n<1:return'zero' t=1000;m=t*t;r='r fif six seven eigh nine ';b=f'one two three four five six seven eight nine ten eleven twelve thir fou{r}twen thir fo{r}'....

posted 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges Find good coalitions

Python 3, 191 bytes lambda p:[c for c in chain(*[C(p,r)for r in range(len(p)+1)])if all(all(i==(sum(p.values())/2>=sum(p[n]for n in d))for d in C(c,len(c)-i))for i in[0,1])] from itertools imp...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges Shuffle a subset of a list

JavaScript (Node.js), 75 68 bytes -7 bytes thanks to Hakerh400 (a,b)=>b.map(i=>[a[i],a[j]]=[a[j=b[Math.random()*b.length|0]],a[i]]) Try it online! Basic random swap algorithm. Unfortuna...

posted 3y ago by Moshi‭  ·  edited 3y ago by Moshi‭

Answer
66%
+2 −0
Challenges Compute the determinant

C, 147 bytes float d(float**m,int r){if(r<2)return**m;int i=r,j;float s=0,*n[--r];for(;i--;s+=(i%2?-1:1)**m[i]*d(n,r))for(j=r;j--;)n[j]=m[j+(j>=i)]+1;return s;} Try it online! Basically ...

posted 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges Weave Strings Together

Python 2, 58 54 bytes lambda l:''.join(filter(None,sum(map(None,'',*l),()))) Try it online! Amazingly, shorter than my Python 3 answer! Uses this method to zip unequal-length lists and this me...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges Weave Strings Together

Python 3, 72 69 bytes lambda l:''.join(sum(zip(*[[*i]+['']*max(map(len,l))for i in l]),())) Try it online! Uses this method to flat zip, with modifications to pad the shorter lists.

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges Decode periodic decimal fractions

JavaScript (Node.js), 242 234 bytes s=>([l,p,i,j,_,r]=/(-)?\+?(\d*)\.?(\d*?)(((\d+)\6|\d)\.|$)/.exec(s),[i,r]=c(c([i|0,1],[j|0,10**(l=j.length)]),[r=r||'0',10**l*(10**r.length-1)]),[(p?-i:i)/(j...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges Abbreviate everything

JavaScript (Node.js), 91 68 65 bytes s=>s.toUpperCase().match(/(?<=^| )[A-Z]|:|;|(?<=[.?!]) /g).join`` Assumes that the original text is properly formatted (has a space after punctuati...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges Expand a polynomial

Challenge Given the roots of a polynomial (that is, the $x$ values where the polynomial evaluates to zero), as an array of real numbers, return the polynomial's coefficients. That is, given real ...

4 answers  ·  posted 2y ago by Moshi‭  ·  last activity 2y ago by Moshi‭

Question code-golf math
66%
+2 −0
Challenges Reverse an ASCII string

Sclipting, (UTF-16) 2 bytes 反 Yay for builtins~

posted 2y ago by Moshi‭

Answer
66%
+2 −0
Challenges Coat of Many Colours

C (gcc), 301 bytes Function taking in an array of null-terminated strings and the array's length. #include <string.h> #include <stdlib.h> char*s="edellowreenrowncarletlackchreachuby...

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer