« first day (1399 days earlier)      last day (3443 days later) » 

4:40 AM
0
A: Sandbox for Proposed Challenges

xnorVerify Minesweeper Board code-golf There have been challenges to generate, solve, and fully implement Minesweeper, but the easier task of verifying a solution has not been posed. I'm posting in the Sandbox mainly to check if this is distinct enough. Your goal is to check whether a completed...

 
 
2 hours later…
7:07 AM
@MartinBüttner If I had the string: "hhellloooo", how would I match "hh", "e", "lll" and "oooo" separately using a regex?
 
7:39 AM
I've found (.)\1+, but that doesn't match "e"...
 
8:01 AM
Replace + with *
 
8:25 AM
@PeterTaylor Is this only PCRE because it doesn't seem to work with Python... :/
It matches the string '11' as '1' and '1' instead of '11'
 
8:36 AM
ughh, weekend coming and no interesting question to solve...
 
i'll whip out a sandboxed question i've been saving for a rainy day
 
grc
@BetaDecay when you have groups in your regex, re.findall() will return the captured groups rather than the whole match
 
@xnor link ?
 
doing an editing pass in the sandbox now: meta.codegolf.stackexchange.com/a/1814/20260
 
8:53 AM
Your verify minesweeper board looks more interesting
 
if you prefer, i'd post that now if I can be convinced it won't be closed for being a dupe
 
Not sure about that
but if it is a dupe now, it is a dupe later on too
Murphy's Law ? <not really>
 
i could change it though
 
Did you do a search for dupes ?
I can do one too.
 
i think my search on minesweeper hit them all
it's just the ones i linked that i'm worried about
i can't imagine any potential dupe not using the word "minesweeper"
 
9:19 AM
@xnor I would say that verifying the board is kind of part of the last question (working minesweeper), but overall its fairly unique
 
ok, thanks
but i'll still let it stew in the sandbox for a bit to see what everyone else thinks
 
@BetaDecay It's as cross-flavour as it's possible to get. The problem is probably with the way you're using it. At a guess, are you extracting the first group, adding its length to the offset, and searching again?
 
 
2 hours later…
10:58 AM
@PeterTaylor x=re.findall("(.)\1*",input())
 
@BetaDecay What are you using the regex for? Is it something you can use .groupby() for instead?
 
@BetaDecay I can't get (.)\1 to work, let alone anything more complicated. What extra incantations does one need?
 
11:13 AM
@PeterTaylor try a raw string r"(.)\1", might be an escaping problem
@BetaDecay ^
 
Yep, that was it. And I've identified your problem.
findall's return value only includes values for groups 1 and up, not for group 0
Observe print(re.findall("((.)\\2*)","hhelllooo"));
> matches are returned in the order found. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group.
Somewhat, ahem, unconventional regex API.
 
@PeterTaylor I'd really recommend using raw strings for all regex patterns, instead of doubling all backslash... it becomes very unreadable for anything more complicated than that... most notably when you're trying to match actual backslashes
 
11:42 AM
@MartinBüttner, the only thing I'm trying to do here is to figure out what weirdness is going on with the match results for Beta Decay. I don't use Python except maybe once or twice for golfing.
 
Hmm what's weird about them?
 
To which comment is that question a reply?
 
Your last one about "what weirdness is going on"
 
That makes sense doesn't it? Since (.) matches the e, but then \1+ fails...
 
Still not getting what's wrong sorry - (.)\1* indeed matches 11 twice. The first match starts from the first 1, putting the first 1 in group 1 then matching \1*, returning the content of group 1 (1). The second match starts from the second 1 and also returns the content of group 1, 1.
Even PCRE matches twice, right? (Or did you mean something else?)
 
12:19 PM
The doc for `re.findall` says

> Return all **non-overlapping matches** of pattern in string, as a list of strings.

(my emphasis)
 
Hmm I see... maybe the \1* that is matched is just the empty string?
Or is it greedy
 
It should be greedy
I think it's probably a bug in re, although it's been around long enough that if it is a bug there'll be resistance to fixing it.
 
>>> import re
>>> print(re.findall(r"(.)\1*", "11"))
['1']
Hmm
 
Ah, Beta Decay's code had two problems.
Failure to use raw strings and re.findall having a dodgy API.
 
>>> print(re.findall("(.)\1*", "11"))
['1', '1']
Ah, raw strings indeed
That makes sense
\1 is ASCII 1 :/
 
12:28 PM
@PeterTaylor Oh yeah, sure, but I figured Beta Decay was actually going to use it.
 
Hey guys I'm back
 
I'm done with regexes
since @Martin's Cn'R
 
12:52 PM
Haha so what's the solution?
 
Use raw strings for your regex :P
 
Or isn't there one?
 
(And depending on what you're using this for, itertools.groupby)
 
@Sp3000 and enclose the entire regex in a group
 
1:03 PM
I feel silly now - I just realised I tested on Regex101 and what I thought was two matches for 11 was just Regex101's difference in highlighting between matched chars in groups and just general matched chars :/ oops
 
1:22 PM
btw, about the stars for the golf-in-chat message... do people actually want to do it? :o
 
 
1 hour later…
2:30 PM
@Sp3000 Easy way to find out: create a new chatroom and start doing it...
 
Ahaha k, sounds like a plan
 
3:02 PM

 Chat minigolf

Participate in codegolf mini-puzzles together!
Well I tried to kickstart it - picked a CheckIO problem because that's what xnor, grc and I were working on when I said that post
I'm not sure what everyone had in mind though - my idea was just to have small problems which wouldn't take too long but would probably be too short/easy for a full PPCG question
So that it works as practice
 
4:00 PM
Some people just can't be helped. (What you can't see is a series of about 15 now deleted comments where two of us tried to explain the deficiencies of the original text, most of which remain).
 
:/ maybe that's the type of puzzle which could benefit from a sandbox
 
4:18 PM
The sandbox doesn't help when the OP won't accept that there's a problem.
 
"Then if nothing else, it is not very clear written that way." Heh.
 
 
3 hours later…
7:17 PM
3
Q: Sandbox on Puzzling?

Beta DecayAlthough the two are fundamentally different, Puzzling and PPCG (Programming Puzzles and Code Golf) are related, and because PPCG is the elder of the two, I think that some ideas should be taken from it. For that reason, I propose that we make a sandbox: a meta question where you post your quest...

 
7:47 PM
0
Q: Sort by code size for code-golf problems

Mohammad Areeb SiddiquiFor easier position calculation and as a handy way for the questioner, a sort by code size feature should be added which would sort out all the answers from the very least byte-ed to the most byte-ed.

 

« first day (1399 days earlier)      last day (3443 days later) »