« first day (4065 days earlier)      last day (781 days later) » 

8:11 PM
CMQ (Python is my preferred language). Given a list of strings, sample one letter with probability proportional to the proportion of times it appears as the first letter of one of the strings
 
so basically take the list of strings, select the first letter of each, and randomly select from that list
 
@hyper-neutrino can that be done golfily?
 
@pxeger re ^ are the strings guaranteed to be all letters?
@Anush well i'm just translating your problem statement to something much easier to describe and understand
 
@hyper-neutrino yes thank you
@pxeger cool!
 
CMQGiven a list of strings, sample one letter with probability proportional to the proportion of times it appears as the first letter of one of the strings and also return the probability of the sampled letter
@DLosc nice!
 
what is the advantage of having the from random import* after the code?
 
it allows you to put f=\​ in the header
 
oh so it's only good for TIO?
(what does f=\ do?)
 
8:29 PM
it assigns the next line to f
 
@Anush Extended Dyalog APL: ?⍤≢⍛⊃⍨⊃¨ Try it online!
 
the \​ tells Python that the next line is part of the same statement/expression
otherwise you get a syntax error
 
@Adám cool!
but now my CMQ has changed a little
 
@Anush Thanks. Want an explanation?
 
@pxeger I see people do in answers on main too.
@Adám yes please!
 
8:31 PM
? random index from length for the argument picks from that same argument [namely] the first ¨ of each.
 
@Anush Pip, 5 bytes: RC@Z_
 
@DLosc whoa!
but the CMQ has changed :)
please everyone move to the new one
 
We see them as 2 separate challenges. Solving one at a time.
 
^
 
@Adám that is a fair point
^
 
8:34 PM
Also, the first one is less involved and therefore more fun (in my totally subjective opinion)
 
@DLosc noooo :)
the second one is cooler
I look forward to the 5 byte pip solution
 
Lol, I doubt it :P
 
:)
 
@DLosc Explanation: same as the Python solution:
    _  Function argument (list of strings)
   Z   Zipped (i.e. transposed)
  @    First element (list of first-characters)
RC     Random choice
 
pretty cool
pip to me is a tool to install python modules :)
 
8:38 PM
Pip to me is the main character of Great Expectations by Charles Dickens ;)
2
 
a much better reference!
 
@Anush (⊢(⊢,+.=÷≢⍤⊣)?⍤≢⊃⊢)⊃¨ Try it online!
 
@Adám that looks clever
how does it work?
 
Just an expansion of the previous, really. ?⍤≢⊃⊢ could in fact have been ?⍤≢⍛⊃⍨
 
I wonder what can be done in python
 
8:44 PM
So ?⍤≢⊃⊢)⊃¨ is equivalent to the previous answer, and ⊢(⊢,+.=÷≢⍤⊣) applies the inner function ⊢,+.=÷≢⍤⊣ with the selected character as right argument and the initials as left argument: the selected character , followed by +.= the sum of vectorised equality ÷ divided by the length of the initials.
 
it's like elvish to me
 
@Anush Pip, 21 bytes: RC{_AL(_N@Za)/#aM@Za}
 
@DLosc pip is pretty magical!
anyone want to try python?
 
is this a CMQ, or do you just want to avoid posting to SO
 
@pxeger It's a CMC really :)
it's not a SO question as I am interested in how golfed it can be
an?
(I also know how to code it in an ungolfed way in python)
 
8:50 PM
Why don't you post what you have already, maybe then people will be more interested
 
or post the wrong answer, then people will be really interested /s
 
coming up
 
ah, good ol' Murphy's Law
;)
 
*pushes up anime glasses* ACTUALLY,
 
@DLosc Here's a pretty gnarly 20 bytes: RC{(_N@:Z:a)/#aMa}Z_
 
8:54 PM
@DLosc wow
 
@pxeger Can this just not be random.choice(w)[0]
 
please make it shorter!
from collections import Counter
words = ["ap", "pear", "aa", "bca", "ppp", "pqr", "pzf"]
c = Counter([word[0] for word in words])
for key in c:
    c[key] = c[key]/len(words)
import random
random.choices([*c.keys()], [*c.values()])[0]
actually this should do
from collections import Counter
words = ["ap", "pear", "aa", "bca", "ppp", "pqr", "pzf"]
c = Counter([word[0] for word in words])
import random
random.choices([*c.keys()], [*c.values()])[0]
how much shorter can it be?
 
@emanresuA ... Yes... -_-
@RC_ in Pip
 
9:03 PM
@pxeger I did as promised :)
although using Counter looks like cheating to me
 
@emanresuA probabilities?
 
The lower number is the relative chance of that appearing. If you want a probability, 10 bytes
 
9:28 PM
the issue is certainly not lack of source material
 
@Anush Oh, so 2 is acceptable instead of 2/7 for the probability?
 
att
9:44 PM
oh i missed a haskell lyal
 
9:58 PM
@att Yeah. :( If you still want to learn you a Haskell, reading through the chat transcript might be enlightening, and we also unfroze the Haskell room.
 
10:18 PM
TIL corn is a fruit
 
@emanresuA cool
 
@Anush You're very mathematically inclined, so I think you'd love APL if you gave it a chance.
 
att
10:54 PM
@DLosc I've meant to for almost 3 years... ;)
 
@Ginger you decided the manufacturing sector was no longer profitable?
 
11:18 PM
Late answers is on fire today
 
Probably because there are Bo2021 bounties on some very old and accessible challenges
 

« first day (4065 days earlier)      last day (781 days later) »