Activity for Moshi
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #282431 | Initial revision | — | over 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) |
— | over 3 years ago |
Edit | Post #282430 | Initial revision | — | over 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) |
— | over 3 years ago |
Comment | Post #281956 |
"Given an array consisting of positive integers" I kind of assumed that the positive integers are single digits because of your examples, but do I have to accept any positive integers? (more) |
— | over 3 years ago |
Comment | Post #282319 |
@user Even if it's exclusive, $[A, B, C, D]$ are the elements 0, 1, 2, **3**; so it ends at 4 not 5. Not that it really matters though if you're changing it to any subset. Though if you'll allow any subset, what would the input be? An array and array of indices? (more) |
— | over 3 years ago |
Comment | Post #282319 |
In any case, to address your questions: Plenty of languages have some sort of randomness function, it's probably fine to just leave the specification as (uniformly) random. This is not a dupe. Also, I personally find it interesting, so there's that. (more) |
— | over 3 years ago |
Comment | Post #282319 |
Is there a mistake in your example? Given $[A, B, C, D, E, F, G, H]$, the 0th index is A and the 5th index is F, so the subset to shuffle would be $[A, B, C, D, E]$. (more) |
— | over 3 years ago |
Comment | Post #280860 |
@Hakerh400 Thanks! (more) |
— | almost 4 years ago |
Edit | Post #280860 |
Post edited: |
— | almost 4 years ago |
Comment | Post #280860 |
@rak1507 lol, does "looking it up" count as an answer to that question? You can derive it pretty easily though by simply assuming that it converges to $F_n(x+1)=rF_n(x)$ (where r is the ratio we want) and plugging it into recurrence equation. (more) |
— | almost 4 years ago |
Edit | Post #280860 |
Post edited: latex fix |
— | almost 4 years ago |
Edit | Post #280860 | Initial revision | — | almost 4 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) |
— | almost 4 years ago |
Edit | Post #280833 |
Post edited: Update to make the solution valid |
— | almost 4 years ago |
Comment | Post #280829 |
Oops, I missed the output criteria. Is it fine to output truthy/falsey values instead of them necessarily being *exactly* two values? (If not, I'll go edit my answer, it's trivial to just tack on a boolean conversion) (more) |
— | almost 4 years ago |
Edit | Post #280833 | Initial revision | — | almost 4 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) |
— | almost 4 years ago |
Comment | Post #279854 |
Is there a point to combining the two functionalities into one? I'm pretty sure that it basically means every answer will just have a `input[0]=='{'?xxx:yyy` (or equivalent) tacked to the front of it. (more) |
— | almost 4 years ago |
Edit | Post #279812 | Initial revision | — | almost 4 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) |
— | almost 4 years ago |
Comment | Post #279778 |
Could you use a character other than ⌷ to separate the graphics? (It's hard for me to tell which side they are 'attached' to) (more) |
— | almost 4 years ago |
Comment | Post #279755 |
"Write a program that halts due to error." Doesn't that mean that almost every programming language would be a solution? (E.g. in your ```main``` example, Java would be a legitimate robber answer since it also fails.) (more) |
— | almost 4 years ago |
Edit | Post #279665 | Post edited | — | almost 4 years ago |
Suggested Edit | Post #279665 |
Suggested edit: Fixed table (have to leave an empty line before table markdown) (more) |
helpful | almost 4 years ago |
Comment | Post #279679 |
@Lundin Thanks for your suggestions! (more) |
— | almost 4 years ago |
Edit | Post #279679 |
Post edited: |
— | almost 4 years ago |
Edit | Post #279679 | Initial revision | — | almost 4 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) |
— | almost 4 years ago |
Edit | Post #279665 | Post edited | — | almost 4 years ago |
Suggested Edit | Post #279665 |
Suggested edit: Moved the table to a collapsible section (more) |
helpful | almost 4 years ago |
Comment | Post #279639 |
(Aside: to mention someone you have to put the full username, without spaces) (more) |
— | almost 4 years ago |
Comment | Post #279639 |
@moony Suggest edits aren't really used for stuff like that; since there are a bunch of limitations (you can't suggest more than one edit, if you change your mind you can't edit your suggested edit, you can't partially incorporate edits etc.) It's much better to use the comments for these sorts of su... (more) |
— | almost 4 years ago |
Edit | Post #279452 |
Post edited: |
— | about 4 years ago |
Edit | Post #279452 | Initial revision | — | about 4 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) |
— | about 4 years ago |
Comment | Post #279444 |
Is there an order we have to output in? (my solution outputs the dimensions in the reverse order of your test cases) (more) |
— | about 4 years ago |
Edit | Post #279256 |
Post edited: |
— | about 4 years ago |
Edit | Post #279256 | Initial revision | — | about 4 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) |
— | about 4 years ago |
Edit | Post #279255 | Post edited | — | about 4 years ago |
Suggested Edit | Post #279255 |
Suggested edit: (more) |
helpful | about 4 years ago |
Comment | Post #279189 |
"that means that you can't just read the source file and print it"
Does JavaScript "toString()" count as reading the source file? (more) |
— | about 4 years ago |
Edit | Post #279166 | Post edited | — | about 4 years ago |
Suggested Edit | Post #279166 |
Suggested edit: (more) |
helpful | about 4 years ago |