Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

6 May, 2024: The networking issue during the past two days has been identified and appears to be fixed. Will keep monitoring.


devel / comp.lang.python / Re: Did i debug this code correctly?

SubjectAuthor
* Did i debug this code correctly?tripd...@gmail.com
`- Re: Did i debug this code correctly?Cameron Simpson

1
Did i debug this code correctly?

<08edb534-487c-46e2-b014-79452faa100dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19567&group=comp.lang.python#19567

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:6214:268a:b0:4a3:a054:cb16 with SMTP id gm10-20020a056214268a00b004a3a054cb16mr23553714qvb.43.1663764600633;
Wed, 21 Sep 2022 05:50:00 -0700 (PDT)
X-Received: by 2002:a05:6808:1719:b0:34d:444a:58c0 with SMTP id
bc25-20020a056808171900b0034d444a58c0mr3693918oib.11.1663764600310; Wed, 21
Sep 2022 05:50:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Wed, 21 Sep 2022 05:49:59 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=102.89.40.7; posting-account=vE4rmAoAAADc1B6gQVwMLSDaz1LAeKj8
NNTP-Posting-Host: 102.89.40.7
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <08edb534-487c-46e2-b014-79452faa100dn@googlegroups.com>
Subject: Did i debug this code correctly?
From: tripdarl...@gmail.com (tripd...@gmail.com)
Injection-Date: Wed, 21 Sep 2022 12:50:00 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2316
 by: tripd...@gmail.com - Wed, 21 Sep 2022 12:49 UTC

I am trying to solve this job task given to my girlfriend and here's the task and what i did

~ The two Python functions liDDA and liB are supposed to solve the same task. Firstly, explain
the task clearly and then fix any semantic errors in the two algorithms (so that they actually do
solve the task correctly).

#Suppose you have found the following (incomplete) Python code on a scrap
#The two Python functions are not quite finished and contain some errors.
-Firstly, give a detailed critique of the incomplete Python code given above. Secondly, fix any syntax errors so that the Python code runs, ensure the code follows good Python coding style and improve all the variable and function names.

def liDDA(a,b,c,d)
P = []
e = c-a
f = d-b
s = max(e,f)
x,y = a,b
for i in range(s):
P.append((round(x), round(y)))
x += e/s
y += f/s
print(P)

liDDA(0,1,6,4)#when running this function i got this
= [(0, 1), (1, 2), (2, 2), (3, 2), (4, 3), (5, 4)]

Second function

#function 2 to do same task
def liB(a,b,c,d)
P = []
e = c-a
f = d-b
g = 2*f - e
y = b
for x in range(a,c+1)
P.append((x,y))
if (g>0)
y += 1
g = g - 2*e
g = g + 2*f
print(P)
liB(0,1,6,4)

Re: Did i debug this code correctly?

<mailman.483.1663797696.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19571&group=comp.lang.python#19571

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs...@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: Did i debug this code correctly?
Date: Thu, 22 Sep 2022 07:54:45 +1000
Lines: 35
Message-ID: <mailman.483.1663797696.20444.python-list@python.org>
References: <08edb534-487c-46e2-b014-79452faa100dn@googlegroups.com>
<YyuIJbcMYwgEI0Q/@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Trace: news.uni-berlin.de nZ0rHYN4vXuNGUeWzroJKQaAiqiKQanyygjERFA8kUeA==
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'comments': 0.03; 'is.':
0.05; 'run.': 0.05; 'variable': 0.05; 'task.': 0.07; 'thing.':
0.07; 'subject:debug': 0.09; 'cheers,': 0.11; 'coding': 0.13;
'syntax': 0.15; '(so': 0.16; 'algorithms': 0.16; 'behaviour':
0.16; 'cameron': 0.16; 'follows': 0.16; 'from:addr:cs': 0.16;
'from:addr:cskk.id.au': 0.16; 'from:name:cameron simpson': 0.16;
'impossible': 0.16; 'message-id:@cskk.homeip.net': 0.16;
'received:13.237': 0.16; 'received:13.237.201': 0.16;
'received:13.237.201.189': 0.16; 'received:cskk.id.au': 0.16;
'received:id.au': 0.16; 'received:mail.cskk.id.au': 0.16;
'simpson': 0.16; 'subject:code': 0.16; 'wrote:': 0.16; 'python':
0.16; 'probably': 0.17; 'solve': 0.19; 'to:addr:python-list':
0.20; 'written': 0.22; 'code': 0.23; 'idea': 0.24; 'task': 0.26;
'visual': 0.26; "isn't": 0.27; 'function': 0.27; 'purpose': 0.28;
'header:User-Agent:1': 0.30; 'unless': 0.32; 'but': 0.32; 'same':
0.34; 'header:In-Reply-To:1': 0.34; 'trying': 0.35; 'received:au':
0.35; 'following': 0.35; 'fix': 0.36; 'errors': 0.36; 'functions':
0.36; 'error,': 0.38; 'two': 0.39; 'quite': 0.39; 'text': 0.39;
'list': 0.39; 'attachments.': 0.39; 'explain': 0.40; 'want': 0.40;
'should': 0.40; 'tell': 0.60; 'inline': 0.61; 'email
addr:gmail.com': 0.63; 'attachments,': 0.64; 'explained': 0.64;
'finished': 0.64; 'received:13': 0.64; 'improve': 0.66;
'received:userid': 0.66; 'subject:this': 0.67; 'generally': 0.67;
'attached': 0.68; 'below': 0.69; 'knowing': 0.71; 'receive': 0.71;
'near': 0.76; 'change,': 0.76; 'supposed': 0.76; '"fix"': 0.84;
'apparent': 0.84; 'task,': 0.84; 'subject:Did': 0.91;
'screenshots': 0.93
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <08edb534-487c-46e2-b014-79452faa100dn@googlegroups.com>
User-Agent: Mutt/2.2.7 (2022-08-07)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <YyuIJbcMYwgEI0Q/@cskk.homeip.net>
X-Mailman-Original-References: <08edb534-487c-46e2-b014-79452faa100dn@googlegroups.com>
 by: Cameron Simpson - Wed, 21 Sep 2022 21:54 UTC

Preamble: this list strips attachments. If you attached some screenshots
orfile attachments, we do no receive them. We generally don't like
screenshots unless they're vital to demonstrating some visual thing. We
_much_ prefer text pasted inline in the message.

So the below is written about a message with no attachments.

On 21Sep2022 05:49, tripd...@gmail.com <tripdarlinq@gmail.com> wrote:
>I am trying to solve this job task given to my girlfriend and here's the task and what i did
>
>~ The two Python functions liDDA and liB are supposed to solve the same task. Firstly, explain
>the task clearly and then fix any semantic errors in the two algorithms (so that they actually do
>solve the task correctly).

Well, as near as I can tell you've not explained the task. It isn't
apparent to me what the purpose of either function is. I can see what
they _do_, but I have no idea why.

Without knowing the intended task, it is impossible to "fix" either of
them because we don't know what the "correct" behaviour should be.

>#Suppose you have found the following (incomplete) Python code on a scrap
>#The two Python functions are not quite finished and contain some errors.
>-Firstly, give a detailed critique of the incomplete Python code given above. Secondly, fix any syntax errors so that the Python code runs, ensure the code follows good Python coding style and improve all the variable and function names.

I don't see any critique either.

What I do see is no comments or docstrings. That would be the first
thing I would want to change, probably followed by more expressive
variable names.

BTW, the second function contains a syntax error, and would not run.

Cheers,
Cameron Simpson <cs@cskk.id.au>

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor