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 1y ago by trichoplax‭

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 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 4y ago by Moshi‭  ·  edited 4y 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 3y ago by Moshi‭

Answer
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 When The Ternary Is Balance

JavaScript (Node.js), 47 40 50 49 bytes -1 (possibly -3) bytes thanks to Shaggy! f=(n,s='0')=>n?f(n/3+n%3/2|0,'')+"+-0+-"[n%3+2]:s Try it online! A basic recursive solution.

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

Answer
71%
+3 −0
Challenges Stairs? Stairs! Stairs.

Python 3, 64 bytes def f(n): for i in range(n):print((' '*(n-i)+'_/'+'##'*i)[3:]) Try it online!

posted 3y ago by Moshi‭

Answer
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
Challenges Convert integer to English

Sclipting, (UTF-16) 454 406 bytes Yes. 塊匱❸곴김分倘標⓶❹演긆륩닆롩닶밎併鈉不終⓷곴김剩❶갾밈分倘⓷標⓷❺演긇끨닷녳눖멤併鈉⓶不終갾밈剩❶뉀分倘⓷標⓷❺演긆둵닦끲뉖밄併鈉⓶不終뉀剩⓶글會⓶倘❷長是긆굮뉂밀⓶終긇끨늗긠뉦뭵댢걦늖눠댶땸긇꽥덦녮긆녩뉶될닦땮뉐❷굀瀰是❶銅긂건덶녮融壹坼❸겠分掘덇밉⓸겠剩倘껐⓶⓹逆⓸終終긆뭮뉒건덶묠덆둲뉖넠뉦뭵댢걦늗뉥긇꽩...

posted 3y ago by Moshi‭  ·  edited 3y 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 3y 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 1y 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 2y ago by Moshi‭  ·  edited 2y 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 3y ago by Moshi‭  ·  edited 3y 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 3y ago by Moshi‭  ·  edited 3y 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 3y 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 3y ago by Moshi‭  ·  edited 3y 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 3y ago by Moshi‭  ·  edited 3y 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 3y ago by Moshi‭  ·  edited 3y 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 3y ago by Moshi‭  ·  edited 3y 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 3y ago by Moshi‭  ·  edited 3y 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 3y ago by Moshi‭  ·  edited 3y ago by Moshi‭

Answer
66%
+2 −0
Challenges Reverse an ASCII string

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

posted 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 3y 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 3y ago by Moshi‭  ·  edited 3y 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