#๐Ÿ”’ Help

47 messages ยท Page 1 of 1 (latest)

undone tartanBOT
#

@timid sequoia

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

timid sequoia
#

I need help with a code

rich hinge
timid sequoia
#

it's not letting me upload the code to ask the question

rich hinge
#

!paste

undone tartanBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

timid sequoia
#

!paste

rich hinge
#

what is the error youa re getting?

timid sequoia
#

the question is You will be given a number of t = 100 rounds of tests you need to pass. For every test you will be given an array of integers a_1, ..., a_n.
The cost of a subsegment of the array a is defined as the number of distinct pair of indexes in that subsegment whose elements are equal.
Divide the array into k non-overlapping subsegments with at least one element, such that each element of the array a belongs to exactly one subsegment.
For every test you will have the below values:
1. The number of the array elements n, and the number of subsegments k, where 2 <= n <= 10 ** 5 and 2 <= k <= min(n, 20)
2. The elements of the array a_1, a_2, ..., a_n, where 1 <= a_i <= n
Find the minimum possible cost of these k subsegments.

#

this error = Error processing data: Unable to allocate 36.3 GiB for an array with shape (69819, 69819) and data type int64 or Killed

rich hinge
#

i think that means you ran out of memory

#

im not the best person to help with that

timid sequoia
#

I just dont know how to fix that issue

latent onyx
#

You need to figure out a different approach.

timid sequoia
#

any ideas?

latent onyx
#

Can you paste the entire error?

#

single letter variable names are really confusing btw

timid sequoia
#

Error processing data: Unable to allocate 39.3 GiB for an array with shape (72596, 72596) and data type int64

latent onyx
#

The full traceback

#

!traceback

undone tartanBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

latent onyx
#

should look something like that

timid sequoia
#

im not getting that traceback error

#

Test 82/100

72596 14
Error processing data: Unable to allocate 39.3 GiB for an array with shape (72596, 72596) and data type int64
[*] Switching to interactive mode

latent onyx
#

I see.

#

How are you running it?

timid sequoia
#

just through wsl using python3

latent onyx
#

Remove the error handler and try it

timid sequoia
#

the error handler?

latent onyx
#

try/except

timid sequoia
#

sorry im very new to python and chatgpt has assisted with most of this code

latent onyx
#

You should not use ChatGPT.

#

Especially if you don't know what you're doing.

#

ChatGPT can and will give you completely unusable code and you wouldn't know it.

timid sequoia
#

hahaha thats why I joined this chat

latent onyx
#

My advice is to revert to a version before you started using ChatGPT and work your solution from there.

timid sequoia
#

running it with no error handler now

latent onyx
#

I'm afraid I can't help debug GPT-generated code.

timid sequoia
#

there is no solution just the question and you have to create a code from that

latent onyx
#

That's your task.

#

Good luck.

timid sequoia
#

ok

undone tartanBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ Help