« first day (3796 days earlier)      last day (1029 days later) » 

6:00 PM
CMC: Write a bijective function which outputs a composite number if given a prime number and a prime number if given a composite number. Bonus points for providing the inverse function
Yes autocorrect, I did in fact mean both objective and bike tire when I typed "bijective" twice
 
@cairdcoinheringaahing I don't think that's possible
 
Is there any way to accomplish that besides just implementing "nth prime number" and "nth composite number" and mapping one to the other?
 
@DLosc except for that
 
@StackMeter It absolutely is
@DLosc I believe so, but it's a CMC, so anything goes
In fact, yes there's basically infinite different bijective by mapping primes to some infinite subset of the naturals, then mapping that subset to the composites. But that method is likely to be the shortest
 
Yeah, that's basically what I meant.
 
6:20 PM
CMC: Given a simple regex (only alphanumeric characters and *, +, and ? repetition operators), output all strings that it fully matches.
2
 
@DLosc what about [ab]*a
how does one eval that
 
You don't have to handle character classes for this CMC.
Though you can if you want to. :)
 
@cairdcoinheringaahing is 1 composite or neither, or can we decide
@DLosc do we have to handle *? and +? non-greedy, or will the input match /([^*+?][*+?]?)*/
 
@DLosc There are infinitely many if there are any * or +.
 
@hyper-neutrino Input will match ^([A-Za-z0-9][*+?]?)*$
 
6:34 PM
@hyper-neutrino 1 is neither, and so will never be an input or output
 
E.g. a+ will match a and aa and aaa etc.
 
@hyper-neutrino wait what do *, + and ? do
ok, that explains + - one or more
 
@Adám Correct, which means the challenge is to make sure that any matching string will be output eventually (assuming infinite time/memory/etc).
 
Oh.
 
@StackMeter * means 0 or more repetitions, + means 1 or more repetitions, ? means 0 or 1 repetitions
 
6:37 PM
so a*b+c? matches any string with 0 or more a's, then 1 or more b's then 0 or 1 c's
so things like aaaaaaabbbbbbc, bbbbbbbbbbbbbbc, aaaaaaaaaaabc are included
 
Correct, and also aabb (0 c's).
 
that is true
I have no idea how you would do this if more than one +/* is involved
that's double infinite recursive
 
^__^
 
one does not simply infinitely recurse more than once
you'd need to know in advance the number of pluses
 
6:44 PM
I think I have an algorithm for it.
 
@cairdcoinheringaahing yuno, 12 bytes: ιPΞ┥i+1ɨ┝ιP‖ (Try it online!)
 
ngn
@DLosc why? a++ is the same as a+
 
i will add built-ins to shorten these down but basically it creates an infinite list of primes, finds the index, adds one, and indexes into the infinite list of non-primes (which includes 1, hence the increment)
 
Basically, start with the shortest string (i.e. set all ? to 0) add a "binary counter" for all repetitions +0/1. Then do the same with +0/1/2, then +0/1/2/3 etc.
 
@DLosc That somewhat makes sense.
@Adám That works for 2, but what about 3 or higher
 
6:47 PM
> etc.
 
@hyper-neutrino oh that's the etc.
 
@StackMeter If you don't want duplicates then remember all you've outputted so far. (inf. memory)
 
ngn
generate all possible strings and filter the ones that match - done :)
 
Right, that's another one. D'oh.
 
@ngn how do you know that that will hit every single possible string
 
6:49 PM
@StackMeter C'mon, that's trivial.
 
i'll be impressed if you manage to generate all strings and not generate all strings
 
ok I'll give you that one @ngn
 
Heh, ngn's method doesn't work if the challenge has an arbitrary regex.
 
ngn
@StackMeter well, start with the empty string, then generate all strings of length 1, then 2, etc. - that will go through all of them
@Adám why?
 
@ngn Because some regexes never terminate.
 
6:51 PM
@ngn Yeah, that's the boring way :)
 
we're looking for the slick way
 
ngn
@Adám all regular automata terminate on finite inputs
 
Sure, but today's regexes are not regular.
 
ngn
@Adám the ones from the cmc are
 
and honestly, I think a Cantor Pairing function would be shorter (it's 6 bytes in Jelly)
 
6:53 PM
> arbitrary
 
ngn
@Adám you said "arbitrary regex". regexes are actually regexes and have always been. pcre-s ("modern regexes") are not regexes.
 
this should theoretically work but it requires infinite steps to start generating items with an f in it (for the test data I have)
 
ngn
@StackMeter the slick way would be to build an automaton and breadth-first search it
 
to make the output more interesting I could cartesian product a bunch of infinite sequences together but idk if itertools handles that
 
> This is the Apocalypse on Pattern Matching, generally having to do with what we call "regular expressions", which are only marginally related to real regular expressions. Nevertheless, the term has grown with the capabilities of our pattern matching engines, so I'm not going to try to fight linguistic necessity here. I will, however, generally call them "regexes" (or "regexen", when I'm in an Anglo-Saxon mood). (source)
 
ngn
6:58 PM
@Adám well, exactly
 
@hyper-neutrino That doesn't theoretically work, precisely because it requires infinite steps before generating some items.
 
@ngn I deliberately used the term "regex" and not "regular expression" ;-)
 
@hyper-neutrino I'd be (pleasantly!) surprised if itertools handled cartesian products of infinite sequences
If so, that's the right tool for the job.
 
ngn
@Adám i'm taking that as a joke
 
@hyper-neutrino if it takes infinite steps to output abcdefgh, I don't think it counts
 
7:01 PM
well idk how that whole infinite automata / turing machine / whatever / the thing WW was talking about a few weeks back theoretically works
is outputting duplicates permitted
actually a simple set() makes it easy to avoid that
 
yes, if it outputs every possible string in guaranteed finite time
 
@hyper-neutrino Sure, duplicates are fine.
 
@ngn indeed, it's only a fraction of the knapsack problem! :þ
 
ngn
the handbag problem :)
 
7:12 PM
@hyper-neutrino I think that's working, yes!
 
@pxeger ok what's the knapsack problem
 
@ngn on the other hand, it's always extremely entertaining :)
 
@pxeger thanks
 
just some trivial python golfs
 
7:18 PM
not bad
@DLosc I'd recommend sandboxing that and seeing if it's good for the main site
 
most would just do ngn's method of iterating through every string, which is boring
 
@rak1507 subject to the constraints every string possible is generated in finite time
 
ngn
@rak1507 what if we iterate through every string and filter the ones that describe apl flaws? would it be entertaining or boring? :P
 
@ngn lol
can you make a regex to match apl flaws?
 
ngn
@rak1507 theoretically, maybe
 
@hyper-neutrino what are the asterisks on the ranges
 
list splat syntax
[*a] = [a[0], a[1], ..., a[-1]]
 
oh ok
 
@StackMeter Yeah, what @rak1507 said. :( Plus, if you do it "properly," it's essentially the same challenge as this.
 
sorry just spent a minute looking through the first 8 pages of the "ok" log and seeing myself on every page multiple times sent my sides into orbit - they'll be coming down in around 2 minutes
 
7:29 PM
@DLosc x nickdrane.com/build-your-own-regex somewhat related
 
@hyper-neutrino Do the upper have to come first? You can get 174 if not
 
@Peilonrayz ah, good idea to import string :p forgot about that thanks
order shouldn't matter as long as all get outputted, so this is perfectly fine
 
[goes to post TIO link to ungolfed reference solution]
"This message is too long."
>:^/
 
you can multiline to make it work
but then users will need to click (see full text) for the link to work
 
is there a reason why the try it online text is always the same?
is there like something that generates it automatically?
 
7:37 PM
@Yorch What text?
 
yeah, Try It Online has formatting options (the link button at the top) and one of those options is SE-submission-style
 
you can also use <esc>, <s>, <g> (not a combination)
 
Oh I hadn't even tried to create the hyperlink yet
no wonder I din't find it
thanks everyone !
 
7:41 PM
@hyper-neutrino Or Github. :P Ungolfed reference solution
 
works as well :P
 
ngn
my eyes hurt from ungolfed code
 
@ngn I made sure to use long_explanatory_variable_names just for you ;)
 
@DLosc this is what Code Review looks like
 
@ngn please post ngn/k on code review
it would be hilarious
 
7:43 PM
pls no
 
ngn
@rak1507 they gonna eat me alive :)
 
let's not
that would be sus
 
@StackMeter Nah, they'd tell me I need better names for my functions, docstrings, put the test code in its own module, etc. :P
 
oh, it doesn't highlight syntax on math stack exchange :/
 
@hyper-neutrino I'm so not used to golfing ofc print(*()) wouldn't work with count... We can -1, to 173, by using count. I'm going to go do some 'proper programming' before I join the dark side ;)
 
7:48 PM
@Peilonrayz Hey, Code Review convinced me (reluctantly) to start using snake_case... if Code Golf rubs off on you, I think it's only a fair exchange ;)
 
@DLosc I've been considering snake_case for a while. What convinced you?
 
I use pascalCase, because it is objectivelySuperior
 
don't need to worry about case when all your variables are one letter long
 
You especially have to worry about case if all your variables are one letter long.
2
 
ngn
@rak1507 jelly fans: what is a "variable"?
 
7:51 PM
what is a good place to learn about decent casing?
 
start at a, end at Z, ignore lower/upper
@ngn lol
 
I just do everything with lower case because I'm a noob
 
@DLosc I'll let you in on a lil tip. I use all the cases ;) ForClass, FOR_CONSANTS and for_variables.
 
@Adám It's the Python standard. If I use camelCase, my variable names don't match the naming style of all the standard library functions, which makes the code look inconsistent. (But I still don't like typing underscores.)
 
part of the reason I like haskell is it lets me pointfree my way out of hard naming decisions :D
 
7:53 PM
0
A: Sandbox for Proposed Challenges

pxegerAre these strings within N bit flips of each other? code-golf string binary decision-problem Given two strings a and b, and a positive integer n, determine if b can be reached by performing exactly n bit-flips on a. A bit-flip is defined as changing one of the bits in the character encoding of a ...

[@SandboxPosts RRREEEDDDWWWOOOLLLFFFF!!!!!]
 
@Peilonrayz Well sure. ;P
 
@DLosc Ah, visual consistency. Right. The keywords in Dyalog APL are all UpperCamelCase…
 
@pxeger is this not a dupe of some hamming distance problem?
 
@Adám Not in QBasic. If you use a in one part of your program and type A by accident somewhere else, the IDE will convert all the previous a's to A's!
 
@rak1507 no, because the same bit can be flipped twice
 
7:55 PM
oh so it's just n = hamming distance mod 2? or something
 
e.g. 1100 -> 1101 -> 1100 is distance 2, not just 0 (and any other even-numbered distance)
 
@DLosc Ah, that's very nice. I had all forgotten that, but what if you load a file that already has a and A?
 
@rak1507 yes I suppose so
 
not convinced it's original enough
 
I didn't really think about that
:(
 
7:55 PM
You have to check is the distance parity is correct and if the distances is smaller than or equal
 
@Adám I assume it picks one and does the conversion... hold on, let me check.
 
ooh, on the other hand an APL solution might let me use ≠⌿⍣≡ which would be pretty cool
 
What bothers me is that thinks like HTMLRenderer and CategoryAXML and JSONToXML are problematic. HTML_renderer and Category_A_XML and JSON_To_XML are much clearer.
 
@Yorch yes, that. But still not much different than plain hamming distance
 
@Adám personally I find the first few easier to read
 
7:57 PM
@rak1507 Yes, my eyes stop up at the underscores instead of seeing the name as a whole, but sometimes it can get pretty confusing if there are multiple consecutive abbreviations.
 
yea that makes sense
 
HTMLToiPhone
 
I_think_the_best_option_is_underscores_between_every_word_and_maintaining_capitalisation_consistancy_with_acronyms_like_NASA_and_proper_nouns_like_Rick_Astley
 
ngn
@Adám call it h and put a comment :)
 
@ngn Problem is that then the spec changes to XHTML, and now you have to change all the hs to xs and it can be rather hard to automate that.
 
7:59 PM
@Adám Yep, it uses the case of the last occurrence.
 
@DLosc Is it possible to run it before it has a chance to edit (or say the file is read-only)?
 
ngn
@Adám if such a necessity ever arises you can keep it as h and claim it's for backwards compatibility :)
 
wHAT¯aBOUT¯rEVERSE¯cAMEL¯sNAKE¯cASE?
 
Unfortunately, Dyalog APL doesn't allow that. Not sure why.
 
@rak1507 Imagine using variables.
 
8:04 PM
@Adám I'm not sure if there's a way to run code directly without opening it in the IDE. The IDE does the autoformatting as soon as you open the file (though you don't have to save it that way if you don't want to). You can type a one-liner and run it from the Immediate window, which doesn't do any formatting, but you can't open an existing code file there.
 
This answer is really clever.
 
@Ausername What answer?
 
@Ausername you haven't linked to an answer
 
Finally, in QB64, there's an option to turn autoformatting off (which I use all the time when golfing).
 
Oops
What do you guys mean?
Of course I linked the answer.
 
8:20 PM
@mods Sorry for the false alarm.
 
:) I see I got ninja'd
 
So did I (:
 
oh hey there art o/
 
We're rich! (Lot's of diamonds…)
 
wait, NPSP skipped a post again?
wack. i just tested it in sandbox and they're running so i guess the socket just shut off at an unlucky time i guess. or something like that
¯\_(ツ)_/¯
 
8:27 PM
Maybe the feed wasn't so bad after all. Better late than never, right?
 
i was worried it'd end up being like this ¯\_(ツ)_/¯ never too late to revert though if we decide we want to
idk if the bot is actually more reliable from my server or if that's just luck - i've run it a minority of the time anyway so it's had less time to fail or die at awkward times
 
@hyper-neutrino I was wondering where the bot was running, and what the reliability would be.
 
I think it's currently still redwolf's, and all failures have been on redwolf's server so far, but again maybe not enough sample size
 
Best to run bots off a data centre…
 
yeah. I have a proper VPS via monthy subscription; redwolf's is in his basement i think lol
 
8:34 PM
When we ran an APL chat bot ourselves, we ran it off a secure centre at a navy base, right next to the UK-French backbone connection
 
I keep my vps in a briefcase I always carry with me
oh wait I got confused with a vpn
 
@Adám i can't tell if you're exaggerating to make a joke or if y'all actually ran a chat bot off a navy base lol
 
If it's in your basement it probably isn't a vps
just a ps
 
well yeah. i have a vps where i run my site, redwolf just has a server computer in his basement or smth
 
@hyper-neutrino Not joking. Gosport, UK.
 
8:36 PM
nice lol
 
I also have a vps for my site
and I recently learned it has better single thread performance than my computer
although my computer isn't very good
it's just a 3600
 
8:50 PM
I wouldn't mind donating a couple of dollars every so often to help cover costs for the chat bots if we hosted them on a reliable server
I think I already pay about $2 a month for TIO (I should double check that tbh), raising that a bit for server space wouldn't be an issue
 
I think running the bots on my server should be completely fine and I already would be paying for that either way and I can afford to add NPSP to it with no issues
 
@hyper-neutrino If you end up running the APL bot, I'm quite sure we'll pay you. (Only reason for not promising anything is that I'm not technically in charge of expenses like that, but considering what we've paid others to do…)
2
 
9:39 PM
ugh, YouTube is so annoying, I keep accidentally cancelling long comments because focus isn't where I think it is :-(
 
 
 
1 hour later…
10:59 PM
@Adám I think they still all terminate eventually though
 
Ah, right, as long as the input is finite, I guess the search (or the universe) much eventually end.
 
11:31 PM
@DLosc that actually makes sense
 
It's not just Aviation SE. Code golf: In as few characters as possible, lick a plane. Code review: Is my plane licking good enough? StackOverflow: I liked a plane, but didn't get the lick-a-plane achievement. What am I missing? Programmers: Is licking a plane an antipattern? Workplace: My boss circulated a memo restating the company policy against plane-licking. Should I quit now, or in two weeks? DIY: Not a hand plane? … etc — kojiro Apr 5 '14 at 17:06
2
 

« first day (3796 days earlier)      last day (1029 days later) »