Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44059
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; '"""': 0.07; 'debugging': 0.07; 'indicating': 0.07; 'problem:': 0.07; 'problem?': 0.07; '22,': 0.09; 'iterate': 0.09; 'next,': 0.09; 'thread': 0.14; 'defined.': 0.16; 'finds': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterates': 0.16; 'wrote:': 0.18; 'shape': 0.19; 'later': 0.20; 'help.': 0.21; 'code,': 0.22; 'error': 0.23; 'mon,': 0.24; 'define': 0.26; 'task': 0.26; 'this:': 0.26; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'reaches': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; 'another': 0.32; 'running': 0.33; 'minimal': 0.33; 'could': 0.34; 'problem.': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'next': 0.36; 'possible': 0.36; 'turn': 0.37; 'list': 0.37; 'city.': 0.38; 'solving': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'new': 0.61; "you're": 0.61; 'first': 0.61; 'connecting': 0.64; 'spot': 0.65; 'charset:windows-1252': 0.65; 'city': 0.66; 'square': 0.74; 'tower,': 0.84; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=23S0sXDmudebb2xEocGXoWQy7o5QvWBA36vdnAsLUJ4=; b=SWy3Ir9PKvTUKvtgxwTaxDThGQ9gG+hwchsros9sqe+z0PLHfwVPYiIosWT/p+Cig4 rfXWg+BCMY6cvSAV3n1JVuMiaAg2UQfPEFg5f72um/oP/GrqqD3fa67xELyzUGfcixkm aGLTC/km13yG/K7fL5lOp+5Z09Mgd1Xzk2EJBC5cyPpTA5jFOkIZxHBXtVIQkkaEBHO8 LootdcycB245qY/OEker6c/41woZT1b3xKkT3Gcdvt2GIaQhCMIpmKKfhCNBFeiIm/S6 cAaQ9RwJtAT0uZgNi42PlofLZsk6O+X3eClljR9HZC/OJfH7RqhnR+HPP61YBAq9W4YO QSlw== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.37.109 with SMTP id x13mr16355388vdj.10.1366635395488; Mon, 22 Apr 2013 05:56:35 -0700 (PDT) |
| In-Reply-To | <09f7da52-b0d6-4167-957f-d207faf33d07@googlegroups.com> |
| References | <09f7da52-b0d6-4167-957f-d207faf33d07@googlegroups.com> |
| Date | Mon, 22 Apr 2013 22:56:35 +1000 |
| Subject | Re: Confusing Algorithm |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.909.1366635404.3114.python-list@python.org> (permalink) |
| Lines | 53 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1366635404 news.xs4all.nl 2217 [2001:888:2000:d::a6]:44478 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:44059 |
Show key headers only | View raw
On Mon, Apr 22, 2013 at 10:39 PM, RBotha <r@ymond.co.za> wrote:
> I'm facing the following problem:
>
> """
> In a city of towerblocks, Spiderman can
> “cover” all the towers by connecting the
> first tower with a spider-thread to the top
> of a later tower and then to a next tower
> and then to yet another tower until he
> reaches the end of the city. Threads are
> straight lines and cannot intersect towers.
> Your task is to write a program that finds
> the minimal number of threads to cover all
> the towers. The list of towers is given as a
> list of single digits indicating their height.
>
> -Example:
> List of towers: 1 5 3 7 2 5 2
> Output: 4
> """
>
> I'm not sure how a 'towerblock' could be defined. How square does a shape have to be to qualify as a towerblock? Any help on solving this problem?
First start by clarifying the problem. My reading of this is that
Spiderman iterates over the towers, connecting his thread from one to
the next, but only so long as the towers get shorter:
First thread
1
New thread
5-3
New thread
7-2
New thread
5-2
There are other possible readings of the problem. Once you fully
understand the problem, write it out in pseudo-code - something like
this:
Iterate over towers sequentially
If next tower is taller than current tower, new thread
Report number of new threads
And then turn it into code, and start running it and playing with
it... and debugging it. (There's a small error in the pseudo-code I
just posted; can you spot it?) Once you're at that point, if you get
stuck, post your code and we can try to help.
But fundamentally, I think you don't _need_ to define a towerblock. :)
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Confusing Algorithm RBotha <r@ymond.co.za> - 2013-04-22 05:39 -0700
Re: Confusing Algorithm Chris Angelico <rosuav@gmail.com> - 2013-04-22 22:56 +1000
Re: Confusing Algorithm Chris Angelico <rosuav@gmail.com> - 2013-04-23 01:02 +1000
Re: Confusing Algorithm Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-22 15:57 +0100
Re: Confusing Algorithm Christian Gollwitzer <auriocus@gmx.de> - 2013-04-22 22:33 +0200
Re: Confusing Algorithm Ian Kelly <ian.g.kelly@gmail.com> - 2013-04-22 16:36 -0600
Re: Confusing Algorithm DJC <djc@news.invalid> - 2013-04-22 22:38 +0100
Re: Confusing Algorithm Tim Roberts <timr@probo.com> - 2013-04-23 23:18 -0700
csiph-web