Computing desk | ||
---|---|---|
< April 18 | << Mar | April | May >> | April 20 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
I'm trying to way to detect all the non-overlapping repetitions within a given string. I Googled it and Stackoverflow gave me an excellent solution that's exactly what I wanted[1], except it doesn't work. To clarify, it appears bug-free and works as advertised for most string, but it's misbehaving for some reason for the type of strings I'm working with:
%2FCatSearch%2F155%2Fengraving-tools%2F32&=%2FCatSearch%2F155%2Fengraving-tools%2F36%2C%2FCatSearch%2F155%2Fengraving-tools%2F32%2C%2FCatSearch%2F155%2Fengraving-tools%2F30%2C%2FCatSearch%2F155%2Fengraving-tools%2F26%2C%2FCatSearch%2F155%2Fengraving-tools%2F21%2C%2FCatSearch%2F155%2Fengraving-tools%2F16%2C%2FCatSearch%2F155%2Fengraving-tools%2F11&v=j&facet=%5B%5B%22vend_name%22%2C%22vend_name%22%2C%22Harvey%22%5D%5D
1. Why is my string not working for the repetitions function?
2. Or alternatively, is there another working solution to the problem? ECS LIVA Z (talk) 20:58, 19 April 2017 (UTC)
(.{6,})(.*\1){3}
will match a string that contains at least 4 (i.e. 3+1) non-overlapping instances of the same substring of length at least 6, and sets $1
to the repeated substring. But I don't know a way to generalize it so that it tells you how many times the substring is repeated. --76.71.6.254 (talk) 22:59, 19 April 2017 (UTC)
def repetitions(s): r = re.compile(r"(.{6,}?)\1+") for match in r.finditer(s): yield (match.group(1), len(match.group(0))/len(match.group(1)))
shazhama
should return ['h',(2,4);'a',(3,5,7);'ha',(2,4)]
.Define N = length(S) Initialize result_list as empty For i from 1 to N For j from i to N Define snippet=S[i:j] If (snippet is not already in result_list) Define list_k = every index such that S[k:k+j-i]==snippet; If list_k contains more than one element Add [snippet, list_k] to result_list End If End If End For End For Return result_list
I want to extend the range of my wi-fi to cover two flats in different floors. For that, I'd want to connect an eth cable to a router's eth port, pass the cable through the stairs (20m), and attach some device at the other end, so that the recipient also gets a wireless connection. I don't want to use a repeater to make the wireless signal more powerful nor those networks through routers connected to the power lines.
What device would I have to connect to the other end of the cable? Would this device also need to be plugged? --Hofhof (talk) 21:03, 19 April 2017 (UTC)
Google Power over Ethernet and ensure that whatever WAP you pickup can be powered in this manner. This is very common, requires no configuration, and is easy to use. 97.102.87.227 (talk) 23:40, 22 April 2017 (UTC) — Preceding unsigned comment added by 97.102.87.227 (talk) 23:39, 22 April 2017 (UTC)