Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106757

Re: Find the number of robots needed to walk through the rectangular grid

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Newsgroups comp.lang.python
Subject Re: Find the number of robots needed to walk through the rectangular grid
Date Sat, 9 Apr 2016 20:23:28 +0100
Lines 39
Message-ID <mailman.137.1460229825.2253.python-list@python.org> (permalink)
References <8c570da8-ab31-44f3-9fdf-83e28741ffe4@googlegroups.com> <CALwzidkhCO0bK2XxP-BZ=aPxuSX-ZiSxq_Yn7pe+ehV8qTsN8Q@mail.gmail.com> <mailman.129.1460220245.2253.python-list@python.org> <e42777b0-fc2b-4f2c-8c2b-a53b41bfe3f7@googlegroups.com> <nebkro$8j2$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de HufE4TZwYL8aSbGM2PcZZwi5CoIzWUlxDvfzJerDUBNg==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'column': 0.07; 'subject:number': 0.07; 'grid': 0.09; 'integers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'successive': 0.09; 'index': 0.13; 'subject: \n ': 0.15; '18:13,': 0.16; '2016': 0.16; 'arbitrarily': 0.16; 'horizontally': 0.16; 'movements,': 0.16; 'nodes': 0.16; 'queue?': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'structure.': 0.16; 'subject:robots': 0.16; 'wrote:': 0.16; 'implementing': 0.18; '(in': 0.18; 'language': 0.19; '>>>': 0.20; 'algorithm': 0.20; 'lawrence': 0.22; 'am,': 0.23; 'code,': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'connected': 0.27; 'checking': 0.27; 'coding': 0.27; 'joe': 0.27; 'cells': 0.29; 'url:wikipedia': 0.29; 'print': 0.30; 'url:wiki': 0.30; "i'd": 0.31; 'post': 0.31; 'anyone': 0.32; 'implement': 0.32; 'language.': 0.32; 'run': 0.33; 'equal': 0.34; 'could': 0.35; 'direction': 0.35; 'comment': 0.35; 'step': 0.36; 'but': 0.36; 'needed': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'thought': 0.37; 'data': 0.39; 'url:en': 0.39; 'subject:the': 0.39; 'build': 0.40; 'to:addr:python.org': 0.40; 'where': 0.40; 'mark': 0.40; 'some': 0.40; 'field': 0.60; 'reach': 0.61; 'charset:windows-1252': 0.62; 'distance': 0.63; 'movement': 0.63; 'saturday,': 0.63; 'our': 0.64; 'between': 0.65; 'legal': 0.66; 'direct': 0.68; 'choose': 0.68; 'sum': 0.69; 'centers': 0.72; 'walk': 0.72; 'transfer': 0.73; 'pythonistas,': 0.84; 'reachable': 0.84; 'standing': 0.84; 'comment.': 0.91; 'robot': 0.91; 'steps.': 0.91; 'divided': 0.93
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host 80.234.134.43
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2
In-Reply-To <e42777b0-fc2b-4f2c-8c2b-a53b41bfe3f7@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
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 <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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <nebkro$8j2$1@ger.gmane.org>
X-Mailman-Original-References <8c570da8-ab31-44f3-9fdf-83e28741ffe4@googlegroups.com> <CALwzidkhCO0bK2XxP-BZ=aPxuSX-ZiSxq_Yn7pe+ehV8qTsN8Q@mail.gmail.com> <mailman.129.1460220245.2253.python-list@python.org> <e42777b0-fc2b-4f2c-8c2b-a53b41bfe3f7@googlegroups.com>
Xref csiph.com comp.lang.python:106757

Show key headers only | View raw


On 09/04/2016 18:13, Joe wrote:
> On Saturday, 9 April 2016 18:44:20 UTC+2, Ian  wrote:
>> On Sat, Apr 9, 2016 at 8:18 AM, Joe  wrote:
>>> How to find the number of robots needed to walk through the rectangular grid
>>> The movement of a robot in the field is divided into successive steps
>>>
>>> In one step a robot can move either horizontally or vertically (in one row or in one column of cells) by some number of cells
>>>
>>> A robot can move in one step from cell X to cell Y if and only if the distance between the centers of the cells X and Y is equal to the sum of integers contained in X and Y
>>>
>>> Cell X is reachable for robot A if either A is currently standing in the cell X or A can reach X after some number of steps. During the transfer the robot can choose the direction (horizontal or vertical) of each step arbitrarily
>>> [![enter image description here][1]][1]
>>>
>>> I started implementing it by first checking the row and print the index of the Cell X and Y where the distance is equal to the sum of integers contained in X and Y
>>>
>>> but after coding I found it difficult to remember the index when moving vertically
>>>
>>>   So I thought to Build a graph where nodes are grid cells and edges are legal direct movements, then run any connected components algorithm to find which cells are reachable from each other
>>>
>>>
>>> Can anyone implement it with graphs or queue?
>>
>> I'd use a disjoint-set data structure. The number of robots needed is
>> equal to the number of disjoint subsets.
>>
>> https://en.wikipedia.org/wiki/Disjoint-set_data_structure
>
> Could you post a formal solution of disjoint-set using my algorithm
>

You write the code, we comment on it.  No code, no comment.  Got the 
message?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Find the number of robots needed to walk through the rectangular grid Joe <lildinho14@gmail.com> - 2016-04-09 07:18 -0700
  Re: Find the number of robots needed to walk through the rectangular grid Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-09 10:43 -0600
    Re: Find the number of robots needed to walk through the rectangular grid Joe <lildinho14@gmail.com> - 2016-04-09 10:13 -0700
      Re: Find the number of robots needed to walk through the rectangular grid Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-04-09 15:10 -0400
      Re: Find the number of robots needed to walk through the rectangular grid Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-04-09 20:23 +0100
        Re: Find the number of robots needed to walk through the rectangular grid Joe <lildinho14@gmail.com> - 2016-04-09 12:41 -0700
          Re: Find the number of robots needed to walk through the rectangular grid Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-04-09 20:55 +0100
            Re: Find the number of robots needed to walk through the rectangular grid Joe <lildinho14@gmail.com> - 2016-04-09 14:28 -0700

csiph-web