« first day (1472 days earlier)      last day (3670 days later) » 
00:00 - 18:0018:00 - 00:00

00:07
@randomra how does mine have a limit?
00:25
you run out of tape
00:41
0
A: Sandbox for Proposed Challenges

PhiNotPiNavigate text with arrow keys code-golf Most (halfway decent) text editors allow you to navigate text using the arrow keys. Up and down allow you to navigate lines, while left and right moves across a line but also wraps around. Furthermore, if the line is shorter than your curser's X positio...

01:25
how the hell do you solve that card pairs game >.<
02:14
You mean on that same Chat Noir website? @mniip
I can't solve it either.
 
1 hour later…
03:18
@MartinBüttner Nevermind the last ping, that was completely silly of me
...and you just pinged him again.
Seems counterproductive.
@MartinBüttner What do you think?
In the meantime, I'll shamelessly advertise for the first question I've posted in over three months.
1
Q: Navigate text with arrow keys

PhiNotPiBackground Most (halfway decent) text editors allow you to navigate text using the arrow keys. Up and down allow you to navigate lines, while left and right move across a line but also wrap around. Furthermore, if the line is shorter than your cursor's X position, the cursor appears at the end...

03:51
What's the worst prime generation algorithm you've ever seen?
I'm pretty sure I just made it for my AP CompSci assignment.
[2]+[n for n in range(3, limit) if 2**n % n == 2]
for(i=2->n)
    parse "https://aprimenumber.com/index.php?prime=" + i
04:34
I guess the worst would be one that didn't compile, and if you made it compile, it would be completely wrong; trying to come up with that kind of code would probably do damage to my brain
 
3 hours later…
07:57
@Sp3000 because you didn't repeat the second group, but I'm sure that's what you figured out ;)
Well I was thinking more "\2 matches empty string, it doesn't repeat the actions of stack-shifting that resulted in said string"
Nothing I've tried have moved more than one empty string except for {n}, annoyingly :/
actually, you only need one stack to show the problem. the simplest example is getting (?<a>)*(?<-a>){3} to match for any number instead of 3
or even (?<a>)*\a (but if you show that to people they'll just say "well remove the *"...)
I think I'll ask in the regex chat
throws arms in air
How about we just write an interpreter in .NET regex instead? :D
08:06
:P
I'm starting to think that the basic problem is backtracking
(?:(?<a>a)|(?<b>b)|(?<-a>A)|(?<-b>B)|(?<a-b>L)|(?<b-a>R))*
ARITHMETIC
Backtracking? How so?
you can't just slap a * on, because (even if it did repeat), it would just repeat the first alternative indefinitely
(greediness and stuff)
Are you talking about (?<a>)*?
well the more general case we had earlier
but yeah that also works
actually no
this one doesn't, because this one would be fixable with an ungreedy quantifier
so take our earlier case with ((?<a>)(?<z>)|(?<-a>))*\z(?(a)!)
if that quantifier worked normally, it would just keeping pushing onto both a and z, because there's nothing stopping it
but if you tried an ungreedy quantifier, it still wouldn't attempt the second alternative, because the first one never fails
If by ungreedy you mean *? the first would never run though...
08:13
well it would backtrack back inside, if the stuff after it fails
but instead of trying the next alternative it would first try adding the first alternative again
take this as an example: (a.|a)*?b matching ababb
zero repetitions doesn't work, so it tries adding a. which does work. but b still fails. so instead of trying the a (which would give a 2-char match), it adds another a., such that the pattern matches all 5 characters
It... captures ab twice?
Oh I see
so I guess it could work if you had mutually exclusive conditions for the alternatives
like ((?(a)!)(?<a>)(?<z>)|\a(?<-a>))*?\z(?(a)!) (in principle, it doesn't work in reality)
I never knew the order you gave alternations actually affected the output... learning something every day...
if we did get that to work, I think it means we're limited to DPDAs (I know that normal DPDAs are less powerful than PDAs, but I don't know if a 2-stack DPDA isn't still Turing complete... after all deterministic Turing machines are)
unless...
hm no, never mind.
basically we'd need a way to make the engine search with a BFS instead of a DFS
(plus, we'd need to convince it to perform the backtracking at all with zero-width groups)
it's sort of disappointing if this was the one quirk that prevented it from being Turing complete :D
Patch it, then use it in the next 5 challenges!
08:22
lol
I don't think such a patch would be desirable for normal regex use ^^
Wish .NET had recursion - that might have helped
lol I said something similar yesterday
maybe we can trick it into a BFS with a couple of auxiliary stacks
but I need to head off for a lecture now
Alternatively an inline flag that lets you switch between left-to-right and right-to-left
I'll give this some thought on the train :D
@Sp3000 you mean a lookbehind? :P
I tried lookbehinds but couldn't get them to work :(
Even something like (?<=(?=...))
08:24
I'm not sure they'd help
they're still 0-width
later!
 
2 hours later…
10:31
@kuroineko your comment on the snake shapes question has me thinking now. I thought my method was correct for all cases but I don't have a proof, so I may have to add redundancy until the current version can be proved correct.
well if you just consider the area swept by a single rotating segment, I see no way in hell you could compute an analytic expression of its surface.
Checking the quarter arc of every point after the pivot for intersection with every line segment up to the one before the pivot and also checking the quarter arc of every point before the pivot for intersection with every line segment from the one after the pivot would be sufficient. That would check every convex point against every line segment, which is enough to convince me. I believe that just checking one of these two ways is sufficient, but for that I am not 100% convinced
well I would be convinced if you used surfaces, but with segments you can still miss a lot of points.
I'm not considering areas at all. I'm only considering the lines swept out by the points, not the areas swept out by the lines. The moving points are checked against the static lines
Yes I agree surfaces would be watertight, but I believe this much easier approach with no surfaces is also watertight (at least in the double case I mentioned just now)
well maybe. I'm not smart enough to follow your algorithm.
10:37
I can't think of a way that two line segments could intersect during a 90 degree rotation that doesn't involve at least one point passing through at least one line segment
I'm pretty sure I'm not the smart one here...
No really, I always was terrible at geometry
I certainly don't think my approach would hold in the general case, it's just a short cut that works because all the line segments are length 1
ok, but the moving segments have anything but integer coordinates
Actually maybe it would still work. I think the key thing is that there are no curves. Since all the lines are straight, there's no way for them to overlap without an end point also overlapping, so we can just check the endpoints against the other lines
I don't think so. The surface swept might collide with points inside a segment without touching either of its ends.
10:42
If the lines were not all the same length then we'd need to check twice, once for the endpoints of line A against the line of line B, then for the endpoints of line B against the line of line A. The two checks are necessary because either of A or B could be the longer one, allowing the shorter one to miss its endpoints. But when all the lines are the same length I think just checking one way is enough.
Yes - this is important. The quarter arc swept out by a moving point may cross a line in the middle and then cross back again before the end of the line. This is covered by checking for intersection of the arc with the line though, so we're safe
What makes me confident is that if the surface collides with any point on a line, then the boundary of that surface (the arc) must also collide with the line.
I think I need diagrams...
but the hull of the swept surface can overflow the quarter arcs
I don't follow
let me show you a picture, if I manage to upload it
That will probably be a lot better :)
My ###ing Internet connection is acting up
I'll try to upload the pic, but I cannot guarantee I'll manage.
10:57
Can you describe it in 1000 words?
OK. Now I understand less :)
red and green are the 1/4 arcs, blue is the swept area.
what did you draw that with?
you can see that the inside of the swept surface is approximately bounded by a circle whose radius is less than arcs
11:00
I can't picture the snake arrangement. Could you specify it as a list of numbers? Like '1120' is a snake that goes straight, straight, anticlockwise, clockwise
@Martin with my faithful PHP, of course
haha, okay
there is no snake, just a segment
A snake of length 1?
no. An horizontal segment of length 4 rotated 90° right
11:02
Ah. I'm with you now.
just to visualize the complexity of the swept area
The line segment is being rotated about a point not aligned to its endpoints. That does complicate things
true, but that can also happen with length 1 segments, right?
With unit length segments the pivot will always be either to the left or to the right, never strictly between the endpoints
11:04
The end points are always on the integer grid, and so is the pivot point. Non-integer points will be passed through during rotation but the start and finish positions will always be integer.
@Sp3000 Okay, so we don't need to model an NPDA... a DPDA is fine, which I think means I only need one valid alternative per iteration - so we don't need any backtracking at all.
that is true in the general case too
Yes, but if I wanted to improve efficiency by considering longer lines, I'd have to think carefully about cases like this where the pivot is between the end points (vertically or horizontally)
Keeping to unit lengths means there are no integers between the ends
give me a second to draw the unit grid on top of the picture
I might need to make another diagram to check, but I believe if you divide your line segments into unit lengths and sweep out the arcs of each of the integer points, then between them then they cut every possible unit integer-aligned line segment within the area you have shown
11:12
say @Zgarb, where do you pull your challenge ideas from? ;)
The circular concave inner edge of the blue area should be the path of one of the integer points.
@MartinBüttner Is Regex Storm the only site that lets you see how many empty strings are in the stack? Trying to see if things are any different elsewhere
Actually not necessarily - I'm just thinking of the unit line segment alone. That has no inner integer points and still sweeps out a concave circular area. I still believe it cuts every possible unit integer-aligned line segment though, which is sufficient.
@Sp3000 does it show you the stack at all? :O
@MartinBüttner The research done at our math department, mostly. We have people working on combinatorics of words, cellular automata, and other fun stuff.
11:15
(I never used regexstorm except to provide links for people without silverlight)
@Zgarb ah, nice :)
I've been using RegexStorm thus far - is says things like "6 captures" which you can expand to see they're all empty trings
oh, awesome
I might actually switch then :D
@Sp3000 for your second sentence, I'm pretty sure they all just pass it on to a .NET instance though... I doubt any of these testers reimplement the flavour
Hmm well that would make sense
(I actually started work on a visualiser once for which I did have to reimplement the ES flavour myself)
it's still in my github account, but I'm not sure when I'll pick it up again (if ever)
Regarding the snake challenge: I don't know how people are currently finding possible positions, but I think it might be easier to generate paths and try to unfold them than start with a line segment and fold it.
11:22
Woops I keep breaking Regex Storm with weird regexes
@trichoplax would that work on this picture? petiteleve.free.fr/SO/_sweep1.png
@PhiNotPi Starting with a straight line and folding all possibilities means checking each step once and only once and only checking illegal shapes that are one illegal step away from a legal one. Checking all possible shapes would involve much more checks (unless you start with all possible shapes that don't self-intersect, but then you still have to generate that set somehow).
@kuroineko I'm safe if no part of the blue area touches a unit axis-aligned line segment that isn't also cut by one of the two blue arcs
well this is equivalent to saying that the two arcs are a boundary of the swept area, right?
@kuroineko The only way it wouldn't be true is if there could be a line segment with both its end points within the blue area, so both blue arcs miss it
There does appear to be such an arc, so I could be in trouble...
11:36
well yes...
I think I'm still safe overall, because that line segment has to be connected to the pivot
If we were testing for intersection of one snake with a disconnected snake, then my method definitely wouldn't work, and you'd need to consider areas as you suggest
nevertheless, if (for some reason beyond my maths) in the case of unit length axis-aligned segments both arcs are guaranteed to be on the boundary of the swept area, then you can easily check if a point is in the area.
about the segment being connected to the pivot, I don't see how that helps. With a long enough snake and after a few bends, you could end up with a snake segment located as far away from the pivot as you want, oriented in any direction.
@kuroineko yes, but at least one of the segments leading back to the pivot would cross at least one of the blue arcs
Mmm... that might seem true intuitively, but is that enough to be sure?
@kuroineko Your diagram actually makes me more confident, but confidence is still just a feeling. I'd like to be able to prove it.
The only route back to the pivot without crossing a blue arc is through one of the line segment ends of the blue area, which don't contain any integer points that aren't also on the blue arcs
11:44
I think that should work.
So this convinces me that the double approach is sufficient (checking all points after the pivot against all segments before the pivot, and vice versa)
But I would still need a proof that the single approach works in order to leave my answer in its current form
Mr Sandbox is about to his first golf badge! :D
well actually I think you could simply check the 4 boundaries of the area, that is the two quarter circles and the two end segments. The quarter circles with a radius comparison, and the segments with the positions relative to the half-plane delimited by the extended lines.
I suspect the areas left out must be within a surface that cannot contain points with integer coordinates.
That should work for any cases where the arcs don't intersect each other.
Actually, even if the arcs cross, the line segments would still have to cross one arc in some direction in order to reach the pivot
well with the restrictions of a 1 unit length and 90° rotation, it seems the two arcs cannot cross each other.
proving that might even be just within the reach of my rusty maths.
11:52
0
A: Sandbox for Proposed Challenges

Martin BüttnerArea of a Self-Intersecting Polygon code-golfgeometry Consider a potentially self-intersecting polygon, defined by a list n ≥ 3 points in 2D space. E.g. {{-2, 0}, {1, 2}, {-3, 4}, {0.5, -0.5}, {0, 3}, {-0.5, -1}} There are several ways to define the area of such a polygon, but the most inter...

@MartinBüttner Well a slightly less naive way could be find all the intersection points then apply Pick's theorem on each subregion, scaled :P
I wonder if you could make use of the area of the triangles between any subset of three points... hmm...
@Sp3000 that's what I was thinking
@MartinBüttner would you be interested in allowing Monte Carlo integration so that different approaches compete to see which is more golfable?
@trichoplax no, Monte Carlo seems pretty boring, and would take forever to get 10^10 accuracy
basically, I want people to compute an analytical solution
which surely exists
@MartinBüttner How about a time limit? I know it's subjective but you could set a large token time limit just to rule out brute force approaches
"shortest code that completes within 1 minute for the following test cases"
12:00
I'd probably rather go with something like "your algorithm's time complexity must be a polynomial in n", but if that turns out to be a bad idea, I might go with a time limit
Or you could make it an hour so that computer differences don't matter so much
Is the time complexity of Monte Carlo O(1)?
Damnit one day I swear I'll learn Ruby for all the regex questions :P
Does increasing the number of vertices increase the number of random measurements required to achieve the given accuracy?
If Martin makes the test cases have really spiky corners, maybe :P
I wonder if you could choose cases that can't reach that level of accuracy with Monte Carlo. If you up the accuracy to make floating point struggle, would that rule out Monte Carlo or analytic methods first?
12:09
@Sp3000 oh, I didn't even notice that you were the author of the other submission
btw, you don't need the \s? in the regex
... point :P
You know, if the input was guaranteed to be valid
You could cut it down to y|mo|d|h|mi|s anyway
yeah, just noticed that :D
88 bytes
86
XD wasn't sure what was allowed or not
Actually I think you can still do a bit better, lemme check...
12:18
neat :)
Think that works
yep
would save me two more bytes, but I don't feel like stealing it ;)
actually, only one byte
Why not? XD Can't catch up anyway
you can save another byte by using a space instead of \s
I forgot this is regex land where spaces actually matter :P
Thanks
Oh I'm silly, I don't need list XD
12:34
you've still got that \s? in there
(in the long version)
Ah oops, thanks :P
Wait...
No that s? is the plural s
... maybe I should just take that out
ah yeah I meant s?
Hey Martin, does Ruby match differently or something? I noticed you have a lookahead in yours
it returned an array when I only had a single group in it, and [0] was longer than the extra two characters for the lookahead
I see... interesting...
12:42
so... back to the real challenge... :D
Well another challenge came out
.. oh you've already commented
nvm that's and, not or :/
13:01
oh I see now what you meant yesterday/this morning how an inline LTR/RTL switch would help
yeah, that would be amazing :D
It'd also be insane if it let you match the same char over and over
with balancing groups it's not like it wouldn't give you more power though
:P
Speaking of regexes I've been thinking of a regex golfer codegolf where you're actually given a regex and the pass/fail sets, and you need to get the shortest regex which matches the sets in the same way via a series of predefined operations (e.g. [x] -> x or abc -> a.c is there is no fail string that matches a.c)
could be interesting as it probably allows you to include more interesting regex features than regex golfing from scratch
I found something weird
both (?<a>)* and (?<a>)+ run the group once
as you can test by appending one ore two copies of (?<-a>)
ummm where exactly can you see the capture stack at regexstorm?
oh, the final column?
13:18
Yeah just under table
I'm not sure why both * and + operate exactly once either...
ah okay, but that table doesn't distinguish between capturing one empty string and capturing nothing
Yeah, that's the only problem (so I've been kicking it off by pushing 5 from the getgo)
lol yeah, I did the same now :D
oh interesting
Hm?
it's not that the backtracking skips empty matches once a quantifier has already found the minimum number of empty repetitions... it's that the quantifier stops altogether as soon as the minimum number of empty repetitions is hit
13:28
@MartinBüttner I think you heard about the idea I was discussing with @PhiNotPi and others. Do you think this would be a candidate for the fortnightly challenges?
... damn
@flawr what idea?
The catch the cat game , assymetrical KOTH game=)
@Sp3000 it seems really weird though, because I think it actually means that * has to be special-cased (as well as {0,n}) so that it runs at all
@flawr ah, sorry, I wasn't following that
ah ok
13:29
I think "asymmetrical koth" sounds like a good fortnightly challenge theme to me
I've been wanting to see that for ages
Geobits has one in his backlog as well I think
and there's an abandoned maze designer/solver proposal in the sandbox
well then I'll post a rough draft in the fortnightly ideas collection
is that ok?
@flawr sure. but just to be clear, I meant for the fortnightly challenge it might be better to not specify the particular game. maybe others have better ideas for our first asymmetrical koth to test the grounds for how well that works. you can always add the game as an example, but I think it might be more fruitful if you left the decision on the actual game open till when it's picked.
ok then I'd better post it in the sandbox, the idea is already pretty concrete
@Sp3000 I wonder if we actually need to able to run for an unspecified amount of steps to claim Turing completeness... I mean Rule 110 doesn't terminate on its own either... you just let it run for long enough until the computation is done, and then you read off the result.
Well the way I see it is if we can get * to work like we want I think we basically have FRACTRAN (I wish I knew more CS so I'd know more about turing-completeness than just esolangs)
13:44
if we get * to work, I think we can probably encode Rule 110, 2-stack DPDAs and maybe cyclic tag systems.
13:55
I wonder if we can abuse that behaviour of * though (that it acts like + on empty patterns)
@PhiNotPi Do you still need a language wrapper?
I suppose I should just go ahead and post a generic wrapper to meta since we're using that as a repository.
That question is loaded. I just said we are. Feel free to explain why you disagree and then I can respond to you properly.
I don't disagree... I'm just not aware of meta being used as a repository, and I'd be interested in an example where we are using it as one.
@flawr Since the idea is pretty concrete already, post it in the sandbox. Fortnightly challenges ideas are a theme, with the challenge being designed by many people in chat.
14:12
@MartinBüttner I can only find the post where we agreed to use meta as a repo. I can't find an actual example of anyone doing it.
oh, right
But if the community likes stack snippet "questions" then they aught to be ok with non javascript code as well.
honestly, I actually never checked back on the outcome of that poll after our last discussion
@Rainbolt agreed
You didn't have to. As soon as I start rooting for one side, you know that is the side that will lose.
lol
actually, I wouldn't really call that a consensus
Peter's answer is a pretty different view and has almost the same net votes (and a downvote less)
in fact, if I could, I might give my answer a downvote, which would make a tie ^^ (and Peter would probably upvote his)
14:15
@Rainbolt I would appreciate a wrapper bundled with compilers, if that's what you said you could make.
I'm talking about the Morra challenge. I have a simple Java controller working.
@Rainbolt Honestly, regardless of the snippets question, I don't see what's wrong with posting a meta question like "How can I run a KotH without restricting submissions to one language?" (or similar... "while still providing subclass entries in the controller language") with a self-answer along the lines of "if you use Java for the controller, you can just use/adapt this wrapper I wrote:"
Tag it [tips][list][java][koth][tag].
2
you need one of the mandatory tags though
I suggest [support]
Oh, replace [java] with the over-generic [discussion].
14:26
I always thought of it more as a .
15:12
@PhiNotPi How quickly do you need it?
No major rush.
 
1 hour later…
16:25
0
A: Sandbox for Proposed Challenges

PhiNotPiCursor Wars king-of-the-hill This question is based off of my previous Navigate Text with Arrow Keys golf. Here, a segment of text is the battle arena, and the opponents move like cursors. Idea 1: Tron / Light-Bikes As the cursors move left to right, they paint parts of the text. Neither cu...

17:09
hm, PhiNotPi's proposal makes me wonder about a KotH similar to Code Bots, where you can collect characters and add them to code of your bot as the game progresses
17:29
@MartinBüttner That might be interesting. A polymorphic code bots.
the actual submission would probably have to be a real-code bot which assembles the "code bots" from the characters, because I doubt you'd be able to actually improve the logic of a bot if that bot itself is responsible for assembling that logic from individual characters
That sounds... tricky.
you'd probably have to keep the game reasonably simple, or the entry barrier will be higher than that of Codemon :P
but I guess a simple entry could just write a strategy for the code bot, and then write an assembler which just adds fixed pieces of code as they become available
might still be too much for PPCG though
0
A: Sandbox for Proposed Challenges

QuadmasterXLIIConway's Golf of Life- Brains vs Brawn Edition 2 programs play a competitive version of the game of life, where each program can set as many cells in the initial condidtions as there are characters in the other's source code. The 2-player game of life is played on an infinite grid of cells. Eac...

LOL what about codémon? It took me a mere 3 hours to get the parser right.
17:43
Yea, sorry again for the IO format :P
@kuroineko I just never bothered parsing half the battle state :D
With Ruby/Python it's easier. Not every language has builtin dictionaries.
Is there a guideline for KOTH controllers? Or a good example?
CarpetPython's controllers are quite good, I think
I haven't seen any really bad ones on any of the more popular koth. Just browsing the top few in the tag should give some nice examples.
17:46
@randomra depends on what you're going for and what language you're comfortable with
I could've sworn we'd done 2P game of life, but not seeing it
I saw one which handled multiple languages in Java or Python i think, if that skeleton is usable it helps a lot that you only need to write in one language
@Geobits there's a sandbox proposal that never got posted
@PhiNotPi Is it available anywhere? If so, it shouldn't be too hard to merge it with the make support from github.com/pjt33/ppcg36515 .
I think it's one of the top-voted ones (if not the topvoted one)
17:50
@Geobits It's definitely been sandboxed before
yeah, just sort by votes
Maybe that's why it seems so familiar :D
I think this is the one I was thinking of. Never made it to main.
@Peter, say... I've been thinking about Turing completeness of things like cyclic tag systeems, Rule 110 and Game of Life... the thing that's bothering me is that all of these don't have any means inside the system to determine if a computation is complete. if you want to use them to compute something, you sort of just have to run it as long as you care to and then hope that you're stuck in a cycle that represents a halting state, right?
@MartinBüttner Although it may make the infrastructure more complex, specifying a "program has ended" symbol that isn't used for anything else seems to solve that problem.
17:59
so you'd generalise the systems to be self-terminating when that symbol pops up?
00:00 - 18:0018:00 - 00:00

« first day (1472 days earlier)      last day (3670 days later) »