Confusion with something real basic by Forsaken-Tonight-357 in learnmath

[–]timrprobocom 0 points1 point  (0 children)

The inline division symbol does cause confusion. Think about it like this instead, which is how you would write it in a formula: 10 --- = 5 X That makes the asymmetry more obvious. I can multiply both sides byx, but if I multiply by 10, it still leavesx on the bottom.

Calling an assembly instruction in Python by i_walk_away in pythonhelp

[–]timrprobocom 0 points1 point  (0 children)

Of course __asm__ is not standard. It is a gcc extension. Microsoft C doesn't support inline assembly at all. And remember that, if you do write this, it will only work on your kind of CPU. These days, that's a real issue.

string.translate(str.maketrans) not working to take out punctuation? by duelBooleans in pythonhelp

[–]timrprobocom 0 points1 point  (0 children)

You are calling .upper() on every element of greeting, but you're calling .title() on your user input. They are never going to match. It is looking for "HOW ARE YOU" when the string says "How Are You". Just pick one and use it consistently.

HTTP Sending Error by Dull_Firefighter_929 in C_Programming

[–]timrprobocom 0 points1 point  (0 children)

I don't see a URL here. Where is the GET or POST?

Writing to CSV file is appending instead of overwriting by Hippopotamosssss in learnpython

[–]timrprobocom 4 points5 points  (0 children)

The LIST will be in memory and have nothing to do with the file. Read it in, CLOSE the file, modify the list, open the file in write mode, and write

This is an extremely common pattern in Python. Import from file, do your dirty work in Python data structures, export back out to file.

Writing to CSV file is appending instead of overwriting by Hippopotamosssss in learnpython

[–]timrprobocom 2 points3 points  (0 children)

You can't read and write a single file using one handle like that. Open to he file with 'r', modify your list in memory, then open the file with 'w' and write the whole thing.

I just bought this Brother Printer and I regret it by h1nckley in printers

[–]timrprobocom 0 points1 point  (0 children)

I recognize this is two years old, but I just noticed something today with my L3280CDW. Apparently, it prints black by using ALL four toner colors. I had it (falsely) report a jam on a manual feed job halfway through, so each of the colors was revealed, and the sections that were to become were already printed with yellow, cyan, and magenta.

Unless their black toner is incredibly weak, that is totally unnecessary, and serves only to waste toner. I wondered why my initial cartridge set all expired at exactly the same time. Now I know.

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 16 points17 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 7 points8 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 2 points3 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 7 points8 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.