« first day (3382 days earlier)      last day (1471 days later) » 

2:20 AM
Awesome! I cleared the latest questions queue.
If that's the case I'm posting my sandboxed question.
 
1
Q: Is the input Bl lu ur rr ry?

Λ̸̸This is based off this challenge. Given an input string, check whether the string is blurry. What's a blurry string? A blurry string is a string that's contained in the set of all blurrified pure-ASCII strings. Take a non-blurrified pure-ASCII string abc as an example. You repeat every charac...

 
2:59 AM
CGCC is playing alive mimicry...
 
3:10 AM
(It's a pun of death mimicry)
0
A: Is the input Bl lu ur rr ry?

JarmexRetina, 16 bytes ^.((.) \2)*.$|^$ Try it online!

 
 
6 hours later…
9:16 AM
In JS I got d=[] and then want to increment its values, e.g. d[3]++
But this doesn't work since d[3] is undefined, and incrementing that results in NaN
Hence, I now write d[j]=d[j]?d[j]+1:1. Any ideas to get that shorter?
Overall, I have c=[1,3,15,20,100,200];d=[];for(i=20;i--;)j=~~(Math.random()*6),d[j]=d[j]?d[j]+1:1;d.map((x,i,_,e=c[i])=>[e,e*x])
Ah, d[j=~~(Math.random()*6)]=d[j]?d[j]+1:1 is trivial optimization
ah d[j=~~(Math.random()*6)]=~~d[j]+1 does it, too!
 
nice
|| has lower precedence than *
 
@JohnDvorak Where should I use it?
 
instead of one of the ~~s
technically &&7 would also work in this case, I suppose
 
you mean j=Math.random()*6||?
Huh
Sorry, I don't get it
 
Bitwise OR coerces to integers
 
9:29 AM
But it also changes the output, no?
E.g. 1.2|2 results in 3
 
ah, sorry; |, not ||. That's even better.
 
e.g. Math.random()*6|1 never results in 0
 
If you choose the right operand correctly, it will only coerce
 
ah just 0
dumb me
 
That's it!
 
9:32 AM
Thank you
somehow I wonder if I can get rid of d=[];, too
 
ngn
@ComFreek which challenge are you solving?
 
None posted here
But here's the description: "Suppose you have coins with values 1, 3, 15, 20, 100, 200. Choose 20 such coins uniformly at random. Sort by coin and print the sums."
intuitition: e.g. output something like "coin with value 1 was chosen 8 times amounting to 1*8=8€, ..."
the program is allowed to output in any data structure as I do above
For reference, here's the current state:
`c=[1,3,15,20,100,200];d=[];for(i=20;i--;)d[j=Math.random()*6|0]=~~d[j]+1;d.map((x,i,_,e=c[i])=>[e,e*x])`
 
ngn
@ComFreek any data structure? :) what if you pack the bits
 
well, would that be allowed on this site?
 
ngn
depends on the definition of any
 
9:38 AM
The challenge is my own (to troll someone who asked "pls giv me teh code" on a forum)
2
so I'd be ready to accept any conventions this site has, too
 
ngn
i don't know if this has ever come up here
 
Which challenges would you recommend beginners?
The top questions often have many answers already
 
ngn
@ComFreek does this look correct? c=[1,3,15,20,100,200];b=0;for(i=20;i--;)b+=1<<5*(Math.random()*6|0);c.map((e,i)=>[e,e*(31&b>>5*i)])
 
Does << or * bind stronger?
 
ngn
@ComFreek *
 
9:52 AM
how I even parse the last subexpression?
31 & (b >> (5*i))?
 
ngn
@ComFreek b encodes what was previously d[0],d[1].. - bits 0 to 4 are reserved for d[0], bits 5 to 7 for d[1], etc. this expression extracts d[i] from b
 
why do you multiply by 5?
 
ngn
(bits are counted from the right of the binary representation)
@ComFreek because the bits for d[i] start from bit number i*5
 
but then I'd have done (Math.random()*6|0) << (5*i)
i.e. I don't see why they should be semantically equivalent
 
ngn
@ComFreek are you sure?
 
9:59 AM
I am not, I am rusty with bit fiddling
 
ngn
@ComFreek in that expression i is between 0 and 20, it's not an index in d
 
oh
 
ngn
@ComFreek btw, you can inline c. it's used only once.
 
What does that mean?
 
ngn
@ComFreek b=0;for(i=20;i--;)b+=1<<5*(Math.random()*6|0);[1,3,15,20,100,200].map((e,i)=>[e,e*(31&b>>5*i)])
 
10:05 AM
oh right
 
ngn
@ComFreek i forgot to reply to this one.. yes - that's how it parses
 
10:17 AM
@ComFreek I think you could use -~d[j] instead of ~~d[j]+1.
 
wow
wait
shouldn't that be equivalent to -1?
 
CMC: Given a value and the exponents of g, cm and s, convert the value to SI units (kg, m, s). Examples: [10, 1, 1, -2] -> 1; [1, 1, -3, 0] -> 1000
 
ngn
10:36 AM
@Neil did you mean [10, 1, -1, -2] for the first example?
@ComFreek .map((e,i)=>[e,e*(31&b>>5*i)]) -> .map(e=>[e,e*(31&b>>5*++i)]) because we know i is -1 before the .map( )
 
nice
 
ngn
@Neil apl, 18 bytes: ⊃×.001 .01 1×.*1↓⊢
 
 
2 hours later…
12:11 PM
@ngn no, I meant [100000, 1, 1, -2], thanks for pointing out my mistake
 
 
5 hours later…
5:37 PM
@ngn Why not take the first element as left argument? ⊣×.001 .01 1×.*⊢ or even simply ×/⊣,.001 .01 1*⊢
 
6:01 PM
Hi! Is this a site where one can ask questions about how to write more efficient versions of a certain program? I have a code in Mathematica that computes 10000 terms of a sequence that appears that appears to be asymptotic to a square root, Sqrt(8*x). Already seeing a plot of the output would be nice. But I suspect that I need to go at least to x=10^6 to see any possible deviations.
 
@MatsGranvik It is on-topic, yes, even though the main focus is saving storage space for the program, not saving CPU resources.
 
ok. Thanks.
 
So in light of that, and greatly reduced traffic here, it might take a while to get an answer, if you get any at all. Have you considered posting on CodeReview.SE?
 
The name code review sounds familiar.
 
 
ngn
7:03 PM
@Adám if we can split it like that, sure, it's simpler. also: ×/⎕,⎕÷1e3 100 1
oops.. i misspoke. that's not multiplication.
 
 
4 hours later…
11:23 PM
0
A: Sandbox for Proposed Challenges

math junkieLength of Longest Non-Repeating Substring code-golf string Your task is to take as input a single string (or list of characters, list of code points, etc.) and return the length of its longest non-repeating substring. Aside: This challenge is similar to Longest Non-Repeating Substring, but wit...

 

« first day (3382 days earlier)      last day (1471 days later) »