Main page: Help searching Wikipedia
How can I get my question answered?
How do I answer a question?
Main page: Wikipedia:Reference desk/Guidelines
Would https://www.akamai.com/blog/security-research/understanding-php2shell-everything-you-need-to-know and https://outcomeschool.com/blog/php2shell be considered reputable sources if I wish to draw a diagram explaining how PHP2Shell works, in a similar style to this explanation for Heartbleed? cmɢʟee τaʟκ (please add {{ping|cmglee}} to your reply) 00:13, 31 October 2026 (UTC)
In a translation project, I would like to translate labels into many different languages. The number of rows of text in each label is fixed but the number of words (delimited by spaces) in the translation is variable. As the Python script cannot tell how wide characters are, assume that each character is the same width (monospace). Instead of linewrapping to a fixed length, I prefer to make each row approximately the same length.
Can someone please describe an algorithm (preferably in python Python 2 with standard libraries) that can split a string into n roughly equal parts at its spaces? If there are fewer than n−1 spaces, the number of rows is reduced (it doesn't hyphenate).
A naive way is to wrap the text at spaces to lines of at most string length/number of rows needed characters. That would fail with, say, "AAAAA B CCCCC DDDD". Ignoring spaces, the length is 15. For 3 rows, the ratio is 5, thus the first row output is "AAAAA". As "B CCCCC" also exceeds 5, the second row output is "B", leaving "CCCCC DDDD" on the third. It should output either "AAAAA B`CCCCC`DDDD" or "AAAAA`B CCCCC`DDDD" ("`" denote hard returns) instead.
An alternative is to brute-force all partitions and choose the one with lowest maximum row length. However, with, say, 10 words and 3 rows, one has to check 120 combinations. Is there a more efficient way?
Thanks, cmɢʟee τaʟκ (please add {{ping|cmglee}} to your reply) 13:01, 8 November 2026 (UTC)
{{ping|cmglee}} to your reply) 12:34, 10 November 2026 (UTC)def split_to_rows(text, n_row): ## split text to up to n_row roughly equal rows
words = text.split()
n_word = len(words)
if n_word <= n_row: return words
i_char_breaks = [0]
for word in words: i_char_breaks.append(i_char_breaks[-1] + len(word))
## segment_length returns length of words[i:j] when joined with single spaces
def segment_length(i,j): return i_char_breaks[j] - i_char_breaks[i] + j - i - 1
target = float(segment_length(0, n_word)) / n_row
## costss[k][j] = minimum cost to split the first j words into k parts
previous_cutss = [[ None ] * (n_word + 1) for k in range(n_row + 1)]
costss = [[float('inf')] * (n_word + 1) for k in range(n_row + 1)]
costss[0][0] = 0.0
for k in range(1,n_row + 1):
for j in range(k,n_word - (n_row - k) + 1): ## j leaves >=1 word in each part
for i in range(k - 1,j):
length = segment_length(i,j)
cost = costss[k - 1][i] + (length - target) ** 2
if cost < costss[k][j]: (costss[k][j], previous_cutss[k][j]) = (cost, i)
## Reconstruct the chosen parts
(cuts, j) = ([n_word], n_word)
for k in range(n_row, 0, -1):
j = previous_cutss[k][j]
cuts.append(j)
return [' '.join(words[cuts[-(k + 1)]:cuts[-(k + 2)]]) for k in range(n_row)]
def split_to_row(text, n_row): return CR.join(split_to_rows(text, n_row))
:import textwrap
:my_text = 'asdf asdffasdf asdf asdf asdfsdfasdf asdf asdfasdfasdf asdfa asdf' * 10
:target_number_of_lines = 8
:max_width = 200
:text_list = None
:# Try wrapping with increasing widths until we get the right number of lines
:for width in range(1, max_width):
: text_list = textwrap.wrap(my_text, width)
: if len(text_list) <= target_number_of_lines:
: break
:if text_list is not None:
: print('\n'.join(text_list))
:else:
: print(f'Text requires greater than {max_width}')
:
{{ping|cmglee}} to your reply) 02:51, 11 November 2026 (UTC)
len(my_text - (target_number_of_lines - 1)) / target_number_of_lines. Even in the ideal case, n characters will need n/target_number_of_lines characters per line, excluding spaces. Replacing each break's space with a newline makes it n − (target_number_of_lines − 1)/target_number_of_lines. cmɢʟee τaʟκ (please add {{ping|cmglee}} to your reply) 03:52, 13 November 2026 (UTC)Has anyone been trying to use Microsoft Copilot and has anyone been successful at using it until 12 November 2026 and then had it stop working and provide a blank screen? (First, I have only been using it to troubleshoot my computer systems. I am not using it to contribute to Wikipedia. I am familiar with the rules.) It stopped working for me on my desktop computer, which is running Windows 11, and is also not working on my laptop computer, which I interpret as meaning that the problem is with the code in the data centers or with access to the data centers. I have restarted Windows and that has not resolved the loss of use of Copilot. Robert McClenon (talk) 22:13, 12 November 2026 (UTC)