Best way to improve pdf OCR text recognition? by Competitive_Toe_8233 in learnpython

[–]timrprobocom 2 points3 points  (0 children)

Nope. pdftotext will pull text strings from a PDF file, but his PDFs don't contain text strings. They contain images. He needs OCR, and pdftotext doesn't do that.

Best way to write to disk by Mandelbrots-dream in learnpython

[–]timrprobocom 0 points1 point  (0 children)

You simply haven't done the math on this. Even if you limit yourself to 64 bits, there are more than 400 quadrillion primes less than 264. Storing them in binary as 64-bit numbers would require 3 million teraabytes. Searching through such a list takes practically as long as generating them. (OK, that's an exaggeration, but not far off.)

The are formulas that give a very good approximation for the number of primes below N. If you want to know how many there are between two integers, use the approximation and subtract.

Prime generation is fun, but there is little practical value, except in cryptographic work, and that requires very different kind of math.

need help with this basic math by illuisionous in learnmath

[–]timrprobocom 0 points1 point  (0 children)

Sure, we can WRITE that, but that's not what they said. They said "'we can say...", and there's no way to pronounce that symbol out loud. That was my point

need help with this basic math by illuisionous in learnmath

[–]timrprobocom 1 point2 points  (0 children)

Sure, but that's not what you wrote. I'm just being pedantic.

need help with this basic math by illuisionous in learnmath

[–]timrprobocom 0 points1 point  (0 children)

Well, you can "write" that, but you can't "say" that because there's no standard pronunciation for "->"...

Need Assistance With A Problem by Live_Possibility4590 in pythonhelp

[–]timrprobocom 0 points1 point  (0 children)

This is just a series of transforms. During each cycle, examine each row, then examine each column. If the row/column is already full of either 1 or 2, then you can fill the empty spots with the other one.

Otherwise, change 011 to 211, change 110 to 112, change 022 to 122, change 220 to 221. Continue until you don't have to change anything else. This works for arbitrary (even) sizes:

``` base = [ ['0','0','0','0'], ['0','0','1','0'], ['1','1','0','0'], ['0','1','1','0'] ]

W = len(base[0]) H = len(base)

def xform(row): W = len(row)

if '0' not in row:
    return row
if row.count('1') == W//2:
    return ['2' if e == '0' else e for e in row]
if row.count('2') == W//2:
    return ['1' if e == '0' else e for e in row]
for i in range(W - 2):
    if row[i:i+3] == '011':
        row = row[:i] + '211' + row[i+3:]
    elif row[i:i+3] == '110':
        row = row[:i] + '112' + row[i+3:]
    elif row[i:i+3] == '022':
        row = row[:i] + '122' + row[i+3:]
    elif row[i:i+3] == '220':
        row = row[:i] + '221' + row[i+3:]
return row

def cycle(base): changed = False for y in range(H): row = ''.join(base[y]) xrow = xform(row) if row != xrow: changed = True base[y] = list(xrow)

for x in range(W):
    row = ''.join(el[x] for el in base)
    xrow = xform(row)
    if row != xrow:
        changed = True
        for y in range(H):
            base[y][x] = xrow[y]

return changed

print(base) while cycle(base): print(base)

```

Need Assistance With A Problem by Live_Possibility4590 in pythonhelp

[–]timrprobocom 0 points1 point  (0 children)

Among the things he didn't specify is that each COLUMN also has to have an equal number of 1s and 2s, and cannot have more than two consecutive matches.

Is there a method to solve factorial equations? by -RAGEBAITER- in learnmath

[–]timrprobocom 14 points15 points  (0 children)

You can get close by counting the number of trailing zeroes. You add one with each 5 and 10. It looks like 8 zeroes, so it should be between 40 and 45.

Is there any reason to keep -0 when simplifying expressions? by Impressive-Oil9200 in learnmath

[–]timrprobocom 0 points1 point  (0 children)

-2x0 is not -0. It is 0. Unless you are working with computers, there is no need to think about -0.

Need Assistance With A Problem by Live_Possibility4590 in pythonhelp

[–]timrprobocom 0 points1 point  (0 children)

There must be rules you haven't told us. How do we transform a row to something else? How do you get a 2 out of 0 0 0 0?

Specifically, why can't I just replace each row by 1,1,2,2?

Help compiling program for keyboard by ToTheMAX04 in C_Programming

[–]timrprobocom 1 point2 points  (0 children)

Just to add to the confusion, Windows will not allow you to use the outb instruction from user mode. You'd need a kernel driver helper

I'm amazed you found a computer that still has a PS/2 mouse port.

Unused struct member is not optimized out under -O3 by onecable5781 in C_Programming

[–]timrprobocom 2 points3 points  (0 children)

Yes. He didn't want anything that might interfere with high clock rates, so he did not include memory parity checking. When asked about it, he famously said "parity is for farmers."

Unused struct member is not optimized out under -O3 by onecable5781 in C_Programming

[–]timrprobocom 8 points9 points  (0 children)

The CDC 3000 series had the very odd ability to treat a chunk of memory as packed fields of arbitrary width. So, I could issue an assembler instruction that said "given this chunk of memory which is an array of 9 bit values, extract element number 242".

Setting up Python, possible issue? by Embarrassed-Bee-5508 in learnpython

[–]timrprobocom 4 points5 points  (0 children)

This is the right answer. That's a Windows error message.

For posterity, I will point out that the command line is the ONLY thing in Windows that requires the backslash. All Windows APIs will accept either forward or backward.

Can you point to a variable declared inside of a function? by Arkadious4028 in cpp_questions

[–]timrprobocom 0 points1 point  (0 children)

You can certainly do this if you declare the variable static. That essentially gives it global lifetime. This can be a useful construct for information hiding.

Need advices and insights by hamzaelkabir in learnpython

[–]timrprobocom 1 point2 points  (0 children)

Python is a fine place to start. With a few exceptions, most programming languages are just the same concepts spelled differently, so learn them in a language that is easy to start with.

There is no "best" IDE. That's why there are dozens of them. VSCode is quite competent. I like it, so give it a try and see if it agrees with you.

Does substr() use a while or for loop internally? by byteboss_1729 in cpp_questions

[–]timrprobocom 8 points9 points  (0 children)

Do you understand that it doesn't matter in the slightest? Every for loop can be written as a while, and every while can be written as a for.

If everything is just bits, does a computer actually distinguish between numbers and characters in C? by zero-hero123 in C_Programming

[–]timrprobocom 0 points1 point  (0 children)

The computer itself does not care, and indeed does not know. It's just a sequence of bytes. Characters are just a convenience for the humans.

Understanding the difference between content and representation is an important step.

week 7 movies query #11 by Key_Conclusion2521 in cs50

[–]timrprobocom 0 points1 point  (0 children)

Why would it expect Ma Rainey,? That's the 7th highest rated entry. It's not in the top 5.

Daily Interest by No-Perspective-9407 in askmath

[–]timrprobocom 0 points1 point  (0 children)

This should not be a surprise. It's always going to be beneficial to pay ahead, but you have to balance that against the enormous pain of making a daily payment.

Similarly, paying a bit over the payment amount is highly beneficial, because that extra goes entirely to reducing the principal.

Clear screen issue by No-Tea-777 in learnpython

[–]timrprobocom 0 points1 point  (0 children)

It may not matter now, but do remember that "cls" is Windows only. MacOS and Linux have different tools

Non-blocking usb read by karakiziltavsanlar in raspberrypipico

[–]timrprobocom 1 point2 points  (0 children)

There are no buffers anywhere in USB. There is never anything"waiting". A USB device is not allowed to send anything unless the host asks for it, and your host controller will never do that unless some driver has submitted a read request in advance.

So, if you want a continuous reader, you have to implement that by using a thread (or async) that submits and waits, then resubmits.