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: 99 Shortened Bottles of Beer
[JavaScript (Node.js)], 228 224 bytes -4 bytes thanks to Hakerh400 ```javascript (b=n=>`${n} bottle${n-1?'s':''} of beer`,w=' on the wall')=>[...Array(99)].map((,i)=>`${b(i=99-i)}${w}, ${b(i)}. `+(--i?`Take one down and pass it around, `:(i=99,`Go to the store and buy some more, `))+b(i)+w+'....
(more)
almost 3 years ago
Answer A: 99 Shortened Bottles of Beer
Sclipting, (UTF-16) 238 bytes ``` 눰 감下❶貶下標⓶긆깯덇끬뉗꼠닶눠눦녥댠❷감侔是검摧終併終❷긆뭮긇끨뉒걷눖롬 껂밀⓹껠뙔눖띥긆뭮뉒걤닷덮긆굮뉂거눗꽳긆땴긆굲닷녮뉂렠⓺❺껠똊終棄棄껠뙇닲건닲건늆넠댷끯댦넠눖멤긆깵뎒걳닶륥긆륯댦넬긃딹긆깯덇끬뉗꼠닶눠눦녥댢걯닢건늆넠덶구닂밎 ``` Explanation ``` 눰 감下 For n from 99 down to 1 ❶貶下 For k from n to n - 1 標⓶긆깯덇끬뉗꼠닶눠눦녥댠 Push " bottles of...
(more)
almost 3 years ago
Answer A: It's Hip to be Square
Sclipting, (UTF-16) 8 bytes ``` 根❶圜同 ``` Takes the square root, pushes a copy, rounds the copy, and compares. Basically, checks that the square root is an integer.
(more)
almost 3 years ago
Answer A: Getting started with making (and/or solving) KOTH challenges
About King of the Hill King of the Hill (KoTH) is a relatively straightforward concept: Entrants create bots; bots compete against each other. Making a KoTH challenge The exact details of the competition can be pretty much anything you want, as long as there is a clear win condition. The mos...
(more)
almost 3 years ago
Answer A: Three Number Monte
MoshiBot ```python from numpy.polynomial import Polynomial def MoshiBot(data, history): if len(history) = 10: cutoff = len(history) - 10 snapshot = history[cutoff:] minvalues = list(map(min, snapshot)) midvalues = list(map(lambda vals: sorted(vals)[1], snapshot)) xpoints = r...
(more)
almost 3 years ago
Answer A: Is it good practice to change the names of variables in challenges?
Yes Unless the challenge tells you what to name your function, you're free to use anything. This means that single character names are usually the best option. Note that anonymous function submissions / lambdas are allowed For that challenge, you don't actually need to submit anything other ...
(more)
almost 3 years ago
Answer A: 1, 2, Fizz, 4, Buzz!
Sclipting, (UTF-16) 62 bytes ``` 감 뉀上標❷갰剩虛끦땺뎠嗎❸걐剩虛뀧녺뎠嗎併梴是⓶終丟終并겠會 ```
(more)
almost 3 years ago
Answer A: Default Rules: Code Golf I/O
Unless explicitly asking for exactly two values, you may use any truthy/falsey values in decision problems For instance, considering the hypothetical challenge "Determine if a number is non-divisible by 3", `n=>n%3` would be a valid solution, as it outputs a truthy (non-zero) value when it is non...
(more)
almost 3 years ago
Answer A: Cumulative Counts
[JavaScript (Node.js)], 34 29 26 bytes -5 bytes thanks to Shaggy's suggestion on a similar challenge -3 bytes again thanks to Shaggy! ```javascript a=>a.map(d=v=>d[v]=-d[v]) ``` Try it online!
(more)
almost 3 years ago
Answer A: Default Rules: Libraries
Language + libraries count as a separate language In the header of your entry, you should have something like this: > ### C (clang) + \, \ You do not need to include the library source in the byte count. However, you must include any import statements in the byte count, as it is considered s...
(more)
almost 3 years ago
Question Default Rules: Libraries
How should we deal with golfing libraries when scoring entries? Continuation of Is my extension-like library allowed to be used in answers?, the answer to that question seems to be a "yes", now we need to figure out how to score it.
(more)
almost 3 years ago
Answer A: Default Rules: Flags and Other Compile-Time Options
I say we follow the established rules on SE: > Rather than dealing with inconsistent schemes for adding flags, let's just consider each separate invocation of a compiler/interpreter/whatever a separate implementation (and thus a separate language by our rules). E.g. Scala `-language:postfixOps`...
(more)
almost 3 years ago
Question Default Rules: Flags and Other Compile-Time Options
How should we deal with flags / command line options when scoring entries?
(more)
almost 3 years ago
Question Add two negabinary integers
About Negabinary Negabinary means base negative two (-2). That is, the $n$th place value is determined by $(-2)^n$. Negabinary numbers can be evaluated just like any other base system. For example, we can parse the numbers 101, 110, and 1010 as follows: | -8 | 4 | -2 | 1 | value | |:--:|:-:...
(more)
almost 3 years ago
Answer A: Shuffle a subset of a list
[JavaScript (Node.js)], 75 68 bytes -7 bytes thanks to Hakerh400 ```javascript (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. Unfortunately, JavaScript doesn't have a built in shuffle function.
(more)
almost 3 years ago
Question Code Golf leaderboard: Scoring tags?
Currently, the leaderboard is useless on alternative-scoring challenges. In order to make the leaderboard more flexible, I propose the creation of two new tags: "lowest-score" and "highest-score". When one of the tags is used; the leaderboard would rank each entry accordingly. What do you all t...
(more)
almost 3 years ago
Answer A: Multiply complex numbers.
[JavaScript (Node.js)], 99 96 69 bytes ```javascript s=>([a,b,c,d]=s.match(/-?\d+/g),ac-bd+(a=ad+bc,a<0?'':'+')+a+'i') ``` Try it online! This regex is probably the best way to get the numbers. Also, for some reason, JavaScript math works with strings of numbers, so that's convenient. ...
(more)
almost 3 years ago
Article Add two negabinary integers [FINALIZED]
About Negabinary Negabinary means base negative two (-2). That is, the $n$th place value is determined by $(-2)^n$. Negabinary numbers can be evaluated just like any other base system. For example, we can parse the numbers 101, 110, and 1010 as follows: | -8 | 4 | -2 | 1 | value | |:--:|:-:...
(more)
almost 3 years ago
Answer A: Evens or Odds - you know this one
[JavaScript (Node.js)], 6 bytes ```javascript n=>n%2 ``` Try it online! Basically does what you'd expect.
(more)
almost 3 years ago
Answer A: Ratio limits of fibonacci-like series
[JavaScript (Node.js)], 27 22 bytes -5 bytes thanks to Hakerh400‭ Direct computation ``` f=n=>(n+(nn+4).5)/2 ``` $$\frac{n+\sqrt{n^2+4}}{2}$$ Try it online!
(more)
about 3 years ago
Answer A: Is it a near-anagram?
[JavaScript (Node.js)], 131 bytes Returns true and false ```javascript g=(s,t,c=[...t])=>([...s].forEach(v=>(y=c.indexOf(v),c.splice(y,y>=0))),c) f=(s,t)=>(x=g(s,t).length)<2&&(y=g(t,s).length)<2&&x+y ``` Try it online! Explanation `g` computes a sort of set (Array?) difference betw...
(more)
about 3 years ago
Answer A: Prime Difference
[JavaScript (Node.js)], 81 bytes ```javascript d=(p,i=2)=>id(p)?f(n,a,p+1):p-a d(p)?f(n, a, p + 1) // Recurse until p is prime // p starts at a+1 so it gets the prime after a :p-a<n?f(n, p):a // If a, p doesn't work, we already computed the next prime so i...
(more)
over 3 years ago
Answer A: Reverse an ASCII string
C, 66 59 bytes -7 bytes thanks to Lundin! In-place string reversal ```c f(chars){s[1]?f(s+1):0;for(char t=s;s[1];++s=t)s=s[1];} ``` Try it online!
(more)
over 3 years ago
Answer A: Shape of an array
JavaScript (Node.js), 39 bytes Returns dimensions from innermost to outermost ```javascript f=a=>a?.pop?f(a[0]).concat(a.length):[] ``` JavaScript (Node.js), 41 bytes Returns dimensions from outermost to innermost ``` f=a=>a?.pop?[a.length].concat(f(a[0])):[] ```
(more)
over 3 years ago
Answer A: Length of a Sumac Sequence
[JavaScript (Node.js)], 27 25 bytes (-2 thanks to JoKing) ```javascript f=(a,b)=>a<0?0:1+f(b,a-b) ``` Try it online!
(more)
over 3 years ago