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 »

Activity for Moshi‭

Type On... Excerpt Status Date
Answer A: Plain black webpage
HTML, 25 bytes ```html {background:#000} ``` Not really sure if this is a legal solution, but technically you can open it in your browser...
(more)
3 months ago
Answer A: Reverse the bits in a Byte
[Sclipting], (UTF-16) 26 bytes ``` 갠긂갠밂乘감뒄뀢감雙갿및剩 ``` Uses a formula I found here >```c >unsigned char b; // reverse this (8-bit) byte >b = (b 0x0202020202ULL & 0x010884422010ULL) % 1023; >```
(more)
9 months ago
Answer A: Mediocre pop count
Python, 89 bytes ```python lambda l,g=lambda c:ord(c).bitcount():[i for i in l if min(map(g,l))<g(i)<max(map(g,l))] ```` Attempt This Online!
(more)
over 1 year ago
Answer A: Just the vowels please
[Sclipting], (UTF-16) 22 bytes ```text 놵멡뉖땯더굅낔뭕뇐虛移 ``` Nothing complicated, just replaces the regex `[^aeiouAEIOU]` with the empty string.
(more)
over 1 year ago
Question Up to date JavaScript Try-It-Online
Try it online doesn't support the latest JavaScript features such as optional chaining or null coalescence, which are very useful character-saving operators. Is there another site like TIO, but which uses an updated JavaScript engine? I don't really want to ask people to copy-paste the code into t...
(more)
over 1 year ago
Answer A: The holeyest base
Sclipting, (UTF-16) 86 bytes ```text 標갠 관上가①要❶❹剩걉눑감⓶重右갰雙⓷加⓶❸分終⓷棄終并❶訂乾⓶折❷同終長괐縮⒈棄丟 ``` Explanation: ```text Input n 標 갠 관上 for b from 2 to 16 가 s = 0 ① n' = n 要 while n' is not 0 ❶❹剩 x = n' mod b 걉눑감 byte array 00 00 01 00 10 01 01 10 00 01 00 01 00 00 00 ...
(more)
over 1 year ago
Answer A: 55 fruit salad: choose your own Kolmogorov complexity
[Python 3], 325 322 bytes -3 bytes thanks to steffan153‭! ```python from base64 import n=int.frombytes(b85decode('8C^#Z9Uor=^}nk`yLA}AWmC>M4TN(sPp`fvySOeqafPpzk0!=hK2{h9DQZ9#JvR$o@^Bj)76Q|8U{@9v3>hyB9Zvx)9|;A2pJv3OHB+p^^q&7X=p=1f0PFWPt=oaR$}kMV<qq(4(9JlEBeS0=2NDO9hjVN+}6JU@C'),'big') while n...
(more)
over 1 year ago
Answer A: Make a frequency table (histogram)
[JavaScript (Node.js)], 38 32 bytes -6 bytes thanks to Shaggy! ```javascript a=>a.map(v=>d[v]=-d[v],d={})&&d ``` Try it online! Basically just this but returning the result
(more)
almost 2 years ago
Question 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 program, ad infinitum. However, you can't just do a quine. The length of each program must tend toward in...
(more)
almost 2 years ago
Article 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 program, ad infinitum. However, you can't just do a quine. The length of each program must tend toward in...
(more)
almost 2 years ago
Answer A: Looping counter
[JavaScript (Node.js)], 31 bytes ```javascript for(i='';;console.log(i+='')); ``` Try it online!
(more)
about 2 years ago
Answer A: Can you give me half?
[Python 3], 5 unique bytes, 28 total ```python (()==())/((()==())+(()==())) ``` `(`, `)`, `=`, `/`, `+` Uses `(()==())` to get `True` with only 3 unique characters, as well as making the later grouping of `(...+...)` free. Try it online!
(more)
about 2 years ago
Answer A: Determine whether an integer is square-free
Japt, 6 bytes -1 byte thanks to Shaggy! k ä¦ e Try it First time doing Japt so this is probably pretty bad. Just factorizes and checks that there are no duplicate factors.
(more)
over 2 years ago
Answer A: Implement Rule 110
[JavaScript (Node.js)], 160 bytes (r,d,n,l=r.length,s=d.length,p=(n,i)=>n?"01110110"[4p(--n,i-1)+2p(n,i)+1p(n,i+1)]:i>=0&i[...Array(4l+s+2n)].map((,i)=>p(n,i-2l-n)) Try it online!
(more)
over 2 years ago
Article Solve a Word Search!
Challenge Given a two-dimensional array of characters and a list of words, output the location of the words. Words can go either vertically top to bottom, horizontally left to right, or diagonally top-left to bottom-right. Output can be given as either the start and endpoint of the array or the...
(more)
over 2 years ago
Answer A: Run-length encode a byte sequence
[JavaScript (Node.js)], 101 82 bytes -19 bytes thanks to Shaggy! ```javascript 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 solved with regexes. Takes input and outputs as hex strings.
(more)
over 2 years ago
Answer A: Convert integer to English
[Python 3], 399 bytes ``` def f(n): if n'') if n>19:s+=b[n//10+17]+'ty'+'-'((n:=n%10)>0) return s+b[n-1]+'teen'(n>12) ``` Try it online!
(more)
over 2 years ago
Answer A: Find good coalitions
[Python 3], 191 bytes ```python 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 import;C=combinations ``` Try it online! Yay for quadruple nested list compressions... ...
(more)
over 2 years ago
Answer A: Convert integer to English
[Sclipting], (UTF-16) 454 406 bytes Yes. ``` 塊匱❸곴김分倘標⓶❹演긆륩닆롩닶밎併鈉不終⓷곴김剩❶갾밈分倘⓷標⓷❺演긇끨닷녳눖멤併鈉⓶不終갾밈剩❶뉀分倘⓷標⓷❺演긆둵닦끲뉖밄併鈉⓶不終뉀剩⓶글會⓶倘❷長是긆굮뉂밀⓶終긇끨늗긠뉦뭵댢걦늖눠댶땸긇꽥덦녮긆녩뉶될닦땮뉐❷굀瀰是❶銅긂건덶녮融壹坼❸겠分掘덇밉⓸겠剩倘껐⓶⓹逆⓸終終긆뭮뉒건덶묠덆둲뉖넠뉦뭵댢걦늗뉥긇꽩뎂걳뉗뉥닢걥늖덨덂걮늖멥긇끥닢걥닆녶뉖먠덇덥닇뉥融壹坼❷掘⓶곀大是덆녥닠終不梴沒뎦녲닰終終終演 ``` Explanation ```text 塊 Function ...
(more)
over 2 years ago
Answer 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 ```python list(iterable) ``` Use ```python [iterable] ```
(more)
over 2 years ago
Answer A: The Ludic Numbers
[Sclipting], (UTF-16) 58 52 bytes ```text 가匱❸增平갠下氫終要鈮貶⓶梴감⓶上❸乘殲終終并鈮掘增 ``` Gives the nth ludic number, 0-indexed. ```text 가 Start list of Ludics with 0 匱❹增平갠下氫終 Create a list of numbers from 2 to n+1 squared 要 While the list is truthy 鈮 Retrieve the Ludic number x (the first elem...
(more)
over 2 years ago
Answer A: Evaluate a single variable polynomial equation
[Python 3], 46 bytes ```python lambda a,x:sum(cxi for i,c in enumerate(a)) ``` Try it online!
(more)
over 2 years ago
Answer A: Weave Strings Together
[Python 2], 58 54 bytes ```python 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 method to flatten the result.
(more)
over 2 years ago
Answer A: Weave Strings Together
[Python 3], 72 69 bytes ```python 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.
(more)
over 2 years ago
Answer A: 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, we use the sequence where every number is one lower. This allows us to compare with 0 in...
(more)
over 2 years ago
Answer A: Expand a polynomial
[JavaScript (Node.js)], 58 bytes ``` ([x,...r],y)=>x?[0,...y=f(r)].map((v,i)=>v-x(y[i]|0)):[1] ``` Try it online!
(more)
over 2 years ago
Answer A: Decode periodic decimal fractions
[JavaScript (Node.js)], 242 234 bytes ```javascript 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',10l(10r.length-1)]),[(p?-i:i)/(j=d(i,r)),r/j]) c=(a,b)=>[a[0]b[1]+b[0]a[1],a[1]b[1]] d=(a,b)=>b?d(b,a%b):a ``` Try it online...
(more)
over 2 years ago
Answer A: Abbreviate everything
[JavaScript (Node.js)], 91 68 65 bytes ```javascript s=>s.toUpperCase().match(/(?<=^| )[A-Z]|:|;|(?<=[.?!]) /g).join`` ``` Assumes that the original text is properly formatted (has a space after punctuation). It converts the string to uppercase, then matches the following: - A letter at...
(more)
over 2 years ago
Question 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 roots $r1, r2, \cdots , rn$, find the coefficients of the expansion of $(x-r1)(x-r2)\cdots(x-rn)$, o...
(more)
over 2 years ago
Answer A: Reverse an ASCII string
[Sclipting], (UTF-16) 2 bytes ``` 反 ``` Yay for builtins
(more)
over 2 years ago
Answer A: Stairs? Stairs! Stairs.
[Python 3], 64 bytes ```python def f(n): for i in range(n):print((' '(n-i)+'/'+'##'i)[3:]) ``` Try it online!
(more)
over 2 years ago
Answer A: 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.
(more)
over 2 years ago
Answer A: "Hello, {name}!"
[Sclipting], (UTF-16) 14 bytes ``` 낆녬닆묬글⑴긐 ```
(more)
over 2 years ago
Question 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 based off an arbitrary number of comparison functions `c1`, `c2`, `c3`, etc.; first sort by comparing u...
(more)
over 2 years ago
Article Expand a polynomial [FINALIZED]
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 roots $r1, r2, \cdots , rn$, find the coefficients of the expansion of $(x-r1)(x-r2)\cdots(x-rn)$, o...
(more)
over 2 years ago
Answer A: Posting guidelines modifications
Since no one has posited anything yet... I think everything but the last three bullets can be kept. Other than that, we could add in the tips about challenge specifications. Challenges > ### Posting Tips > > - Your title should be a one sentence summary of your question. > - Break differe...
(more)
over 2 years ago
Answer A: Make my value binary
[Sclipting], (UTF-16) 14 bytes ``` 要감啃終丟併反 ``` Explanation: ```text Push input 要 While the top number is non-zero 감啃 Shift the top number by 1 bit and push both the bit and shifted result 終 End loop 丟併反 Drop leading zero, concatenate, and reverse ```
(more)
over 2 years ago
Answer A: "Hello, World!"
[Sclipting], (UTF-16) 18 bytes ``` 낆녬닆묬긅덯댦롤긐 ``` Since it hasn't been added yet.
(more)
over 2 years ago
Answer A: Compute the determinant
C, 147 bytes ```c float d(floatm,int r){if(r=i)]+1;return s;} ``` Try it online! Basically a C version of my example code. Takes an array of pointers and the size. Prettified and commented version: ```c float d(float m, int r) { if(r = i)] + 1; // (j >= i) term skips over ...
(more)
over 2 years ago
Question Compute the determinant
Challenge A simple challenge: Given a two-dimensional matrix (an array of arrays) of real numbers, compute the determinant. The determinant of a matrix is a mathematical construct used in many applications, such as solving polynomial equations, identifying the invertibility of the matrix, and f...
(more)
over 2 years ago
Article 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 based off an arbitrary number of comparison functions `c1`, `c2`, `c3`, etc.; first sort by comparing u...
(more)
over 2 years ago
Answer A: My house is destroyed! Can you make me one?
[Python 3], 47 42 40 bytes -2 bytes thanks to bastolski ```python lambda n:'#'n+('\n#'+' '(n-2)+'#')-n ``` Try it online! Python's string multiplication is really useful.
(more)
over 2 years ago
Question Roll n fair dice
Challenge This is a simple randomness challenge: Given a non-negative integer $n$, and positive integer $m$, simulate rolling and summing the results of $n$ fair dice, each of which have $m$ sides numbered $1$ through $m$. Here is a basic ungolfed example in Python: ```python from random im...
(more)
over 2 years ago
Answer A: In The Jailhouse Now
[Sclipting], (UTF-16) 80 bytes ``` 갰減먩놔 먩놦①復먩놗겮꺕똀 먩놬①復①增疊먩놣겮꺕똀會먩놣겮꺕떠 먩놩⑴復먩놝 ``` Explanation ``` Input n pushed on stack 갰減 Subtract 3 먩놔 "╔" 먩놦 "╦" ①復 String of above repeated n-3 times 먩놗겮꺕똀 "╗\n╠" 먩놬 "╬" ①復 String of above repeated ...
(more)
over 2 years ago
Answer A: Default Rules: Extensions
Implementation defines the language, so if you use extensions to a language, you should add ` + ... extensions` to the header. E.g. for a C post using gcc extensions, the header begin with ```markdown C (gcc) + gcc extensions ```
(more)
over 2 years ago
Question Default Rules: Extensions
Since there have been some discussions about the use of GCC extensions, I decided to make a default-rules post about it. How should we deal with compiler extensions to languages?
(more)
over 2 years ago
Answer A: Coat of Many Colours
[C (gcc)], 301 bytes Function taking in an array of null-terminated strings and the array's length. ```c #include #include chars="edellowreenrowncarletlackchreachubyliveioletawnilacoldhocolateauvereamrimsonilverosezuremonussetreyurplehiteinkrangelue";int g(const voida,const voidb){return s...
(more)
over 2 years ago
Article Compute the determinant
Challenge A simple challenge: Given a two-dimensional matrix (an array of arrays) of real numbers, compute the determinant. The determinant of a matrix is a mathematical construct used in many applications, such as solving polynomial equations, identifying the invertibility of the matrix, and f...
(more)
over 2 years ago
Answer A: Coat of Many Colours
[JavaScript (Node.js)], 153 147 bytes -6 bytes thanks to Shaggy! ``` a=>a.sort((x,y)=>g(x)-g(y),g=x=>"y gree br sc bla oc pe rub ol v f li go ch m cre c s ro a l ru g pu w p o b".split` `.findIndex(t=>!x.indexOf(t))) ``` Try it online! Inspired by user's solution, I found the minimum nu...
(more)
over 2 years ago
Answer A: A chunk of symbols is a calculation
[JavaScript (Node.js)], 148 bytes ```javascript s=>s?eval(s.replace(/([^()])\1/g,(m,g)=>(g=='!'?'+':g)+m.length).replace(/\(/g,'(').replace(/-(\d|\(.+?\))\^(\d+)/g,(m,g,h)=>'-('+g+''+h+')')):0 ``` Abuses regex replacements and evals. Is it pretty? Nope. Is it optimized? Nope. Does it work? Ma...
(more)
over 2 years ago