Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79788 > unrolled thread
| Started by | emmanueloje@gmail.com |
|---|---|
| First post | 2014-10-27 08:10 -0700 |
| Last post | 2014-10-29 18:03 +0000 |
| Articles | 16 — 13 participants |
Back to article view | Back to comp.lang.python
Anyone know the solution emmanueloje@gmail.com - 2014-10-27 08:10 -0700
Re: Anyone know the solution alister <alister.nospam.ware@ntlworld.com> - 2014-10-27 15:21 +0000
Re: Anyone know the solution Joel Goldstick <joel.goldstick@gmail.com> - 2014-10-27 11:20 -0400
Re: Anyone know the solution Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-27 20:18 -0400
Re: Anyone know the solution Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-28 00:20 +0000
Re: Anyone know the solution alex23 <wuwei23@gmail.com> - 2014-10-28 10:33 +1000
Re: Anyone know the solution Anton <anton.schattenfeld@gmail.com> - 2014-10-28 18:28 -0700
Re: Anyone know the solution alex23 <wuwei23@gmail.com> - 2014-10-29 12:03 +1000
Re: Anyone know the solution Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-10-29 18:13 +1300
Re: Anyone know the solution Anton <anton.schattenfeld@gmail.com> - 2014-10-29 17:09 -0700
Re: Anyone know the solution Terry Reedy <tjreedy@udel.edu> - 2014-10-28 00:24 -0400
Re: Anyone know the solution "Mario R. Osorio" <nimbiotics@gmail.com> - 2014-10-28 08:38 -0700
Re: Anyone know the solution ngangsia akumbo <ngangsia@gmail.com> - 2014-10-28 09:07 -0700
Re: Anyone know the solution Cameron Simpson <cs@zip.com.au> - 2014-10-29 11:53 +1100
Re: Anyone know the solution Dave Angel <davea@davea.name> - 2014-10-28 22:11 -0400
Re: Anyone know the solution Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-29 18:03 +0000
| From | emmanueloje@gmail.com |
|---|---|
| Date | 2014-10-27 08:10 -0700 |
| Subject | Anyone know the solution |
| Message-ID | <43dce2d9-38ef-462c-bb52-897d827e50c5@googlegroups.com> |
Write a program that reads the contents of the two files into two separate lists. The user should be able to enter a boy's name, a girl's name or both, and the application will display messages indicating whether the names were among the most popular. THIS IS THE LIST OF BOY NAMES Jacob Michael Joshua Matthew Daniel Christopher Andrew Ethan Joseph William Anthony David Alexander Nicholas Ryan Tyler James John Jonathan Noah Brandon Christian Dylan Samuel Benjamin Zachary Nathan Logan Justin Gabriel Jose Austin Kevin Elijah Caleb Robert Thomas Jordan Cameron Jack Hunter Jackson Angel Isaiah Evan Isaac Mason Luke Jason Gavin Jayden Aaron Connor Aiden Aidan Kyle Juan Charles Luis Adam Lucas Brian Eric Adrian Nathaniel Sean Alex Carlos Bryan Ian Owen Jesus Landon Julian Chase Cole Diego Jeremiah Steven Sebastian Xavier Timothy Carter Wyatt Brayden Blake Hayden Devin Cody Richard Seth Dominic Jaden Antonio Miguel Liam Patrick Carson Jesse Tristan Alejandro Henry Victor Trevor Bryce Jake Riley Colin Jared Jeremy Mark Caden Garrett Parker Marcus Vincent Kaleb Kaden Brady Colton Kenneth Joel Oscar Josiah Jorge Cooper Ashton Tanner Eduardo Paul Edward Ivan Preston Maxwell Alan Levi Stephen Grant Nicolas Omar Dakota Alexis George Collin Eli Spencer Gage Max Cristian Ricardo Derek Micah Brody Francisco Nolan Ayden Dalton Shane Peter Damian Jeffrey Brendan Travis Fernando Peyton Conner Andres Javier Giovanni Shawn Braden Jonah Cesar Bradley Emmanuel Manuel Edgar Erik Mario Edwin Johnathan Devon Erick Wesley Oliver Trenton Hector Malachi Jalen Raymond Gregory Abraham Elias Leonardo Sergio Donovan Colby Marco Bryson Martin THIS IS THE LIST OF GIRLS NAME Emily Madison Emma Olivia Hannah Abigail Isabella Samantha Elizabeth Ashley Alexis Sarah Sophia Alyssa Grace Ava Taylor Brianna Lauren Chloe Natalie Kayla Jessica Anna Victoria Mia Hailey Sydney Jasmine Julia Morgan Destiny Rachel Ella Kaitlyn Megan Katherine Savannah Jennifer Alexandra Allison Haley Maria Kaylee Lily Makayla Brooke Mackenzie Nicole Addison Stephanie Lillian Andrea Zoe Faith Kimberly Madeline Alexa Katelyn Gabriella Gabrielle Trinity Amanda Kylie Mary Paige Riley Jenna Leah Sara Rebecca Michelle Sofia Vanessa Jordan Angelina Caroline Avery Audrey Evelyn Maya Claire Autumn Jocelyn Ariana Nevaeh Arianna Jada Bailey Brooklyn Aaliyah Amber Isabel Danielle Mariah Melanie Sierra Erin Molly Amelia Isabelle Madelyn Melissa Jacqueline Marissa Shelby Angela Leslie Katie Jade Catherine Diana Aubrey Mya Amy Briana Sophie Gabriela Breanna Gianna Kennedy Gracie Peyton Adriana Christina Courtney Daniela Kathryn Lydia Valeria Layla Alexandria Natalia Angel Laura Charlotte Margaret Cheyenne Mikayla Miranda Naomi Kelsey Payton Ana Alicia Jillian Daisy Mckenzie Ashlyn Caitlin Sabrina Summer Ruby Rylee Valerie Skylar Lindsey Kelly Genesis Zoey Eva Sadie Alexia Cassidy Kylee Kendall Jordyn Kate Jayla Karen Tiffany Cassandra Juliana Reagan Caitlyn Giselle Serenity Alondra Lucy Kiara Bianca Crystal Erica Angelica Hope Chelsea Alana Liliana Brittany Camila Makenzie Veronica Lilly Abby Jazmin Adrianna Karina Delaney Ellie Jasmin
[toc] | [next] | [standalone]
| From | alister <alister.nospam.ware@ntlworld.com> |
|---|---|
| Date | 2014-10-27 15:21 +0000 |
| Message-ID | <rqt3w.638325$Ym.218381@fx05.am4> |
| In reply to | #79788 |
On Mon, 27 Oct 2014 08:10:04 -0700, emmanueloje wrote: > Write a program that reads the contents of the two files into two > separate lists. The user should be able to enter a boy's name, a girl's > name or both, and the application will display messages indicating > whether the names were among the most popular. > Your tutor for a start & I think I could probably get one working in an hour or so without too much difficulty. What do you have? we do not do homework for you here. if you have some code that doesn't work as expected we may assist -- semper en excretus
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2014-10-27 11:20 -0400 |
| Message-ID | <mailman.15236.1414423717.18130.python-list@python.org> |
| In reply to | #79788 |
2014-10-27 11:10 GMT-04:00 <emmanueloje@gmail.com>: > Write a program that reads the contents of the two files into two separate lists. The user should be able to enter a boy's name, a girl's name or both, and the application will display messages indicating whether the names were among the most popular. > > THIS IS THE LIST OF BOY NAMES > Jacob > Michael > Joshua > Matthew > Daniel > Christopher > Andrew > Ethan > Joseph > William > Anthony > David > Alexander > Nicholas > Ryan > Tyler > James > John > Jonathan > Noah > Brandon > Christian > Dylan > Samuel > Benjamin > Zachary > Nathan > Logan > Justin > Gabriel > Jose > Austin > Kevin > Elijah > Caleb > Robert > Thomas > Jordan > Cameron > Jack > Hunter > Jackson > Angel > Isaiah > Evan > Isaac > Mason > Luke > Jason > Gavin > Jayden > Aaron > Connor > Aiden > Aidan > Kyle > Juan > Charles > Luis > Adam > Lucas > Brian > Eric > Adrian > Nathaniel > Sean > Alex > Carlos > Bryan > Ian > Owen > Jesus > Landon > Julian > Chase > Cole > Diego > Jeremiah > Steven > Sebastian > Xavier > Timothy > Carter > Wyatt > Brayden > Blake > Hayden > Devin > Cody > Richard > Seth > Dominic > Jaden > Antonio > Miguel > Liam > Patrick > Carson > Jesse > Tristan > Alejandro > Henry > Victor > Trevor > Bryce > Jake > Riley > Colin > Jared > Jeremy > Mark > Caden > Garrett > Parker > Marcus > Vincent > Kaleb > Kaden > Brady > Colton > Kenneth > Joel > Oscar > Josiah > Jorge > Cooper > Ashton > Tanner > Eduardo > Paul > Edward > Ivan > Preston > Maxwell > Alan > Levi > Stephen > Grant > Nicolas > Omar > Dakota > Alexis > George > Collin > Eli > Spencer > Gage > Max > Cristian > Ricardo > Derek > Micah > Brody > Francisco > Nolan > Ayden > Dalton > Shane > Peter > Damian > Jeffrey > Brendan > Travis > Fernando > Peyton > Conner > Andres > Javier > Giovanni > Shawn > Braden > Jonah > Cesar > Bradley > Emmanuel > Manuel > Edgar > Erik > Mario > Edwin > Johnathan > Devon > Erick > Wesley > Oliver > Trenton > Hector > Malachi > Jalen > Raymond > Gregory > Abraham > Elias > Leonardo > Sergio > Donovan > Colby > Marco > Bryson > Martin > > THIS IS THE LIST OF GIRLS NAME > Emily > Madison > Emma > Olivia > Hannah > Abigail > Isabella > Samantha > Elizabeth > Ashley > Alexis > Sarah > Sophia > Alyssa > Grace > Ava > Taylor > Brianna > Lauren > Chloe > Natalie > Kayla > Jessica > Anna > Victoria > Mia > Hailey > Sydney > Jasmine > Julia > Morgan > Destiny > Rachel > Ella > Kaitlyn > Megan > Katherine > Savannah > Jennifer > Alexandra > Allison > Haley > Maria > Kaylee > Lily > Makayla > Brooke > Mackenzie > Nicole > Addison > Stephanie > Lillian > Andrea > Zoe > Faith > Kimberly > Madeline > Alexa > Katelyn > Gabriella > Gabrielle > Trinity > Amanda > Kylie > Mary > Paige > Riley > Jenna > Leah > Sara > Rebecca > Michelle > Sofia > Vanessa > Jordan > Angelina > Caroline > Avery > Audrey > Evelyn > Maya > Claire > Autumn > Jocelyn > Ariana > Nevaeh > Arianna > Jada > Bailey > Brooklyn > Aaliyah > Amber > Isabel > Danielle > Mariah > Melanie > Sierra > Erin > Molly > Amelia > Isabelle > Madelyn > Melissa > Jacqueline > Marissa > Shelby > Angela > Leslie > Katie > Jade > Catherine > Diana > Aubrey > Mya > Amy > Briana > Sophie > Gabriela > Breanna > Gianna > Kennedy > Gracie > Peyton > Adriana > Christina > Courtney > Daniela > Kathryn > Lydia > Valeria > Layla > Alexandria > Natalia > Angel > Laura > Charlotte > Margaret > Cheyenne > Mikayla > Miranda > Naomi > Kelsey > Payton > Ana > Alicia > Jillian > Daisy > Mckenzie > Ashlyn > Caitlin > Sabrina > Summer > Ruby > Rylee > Valerie > Skylar > Lindsey > Kelly > Genesis > Zoey > Eva > Sadie > Alexia > Cassidy > Kylee > Kendall > Jordyn > Kate > Jayla > Karen > Tiffany > Cassandra > Juliana > Reagan > Caitlyn > Giselle > Serenity > Alondra > Lucy > Kiara > Bianca > Crystal > Erica > Angelica > Hope > Chelsea > Alana > Liliana > Brittany > Camila > Makenzie > Veronica > Lilly > Abby > Jazmin > Adrianna > Karina > Delaney > Ellie > Jasmin > -- > https://mail.python.org/mailman/listinfo/python-list The answer to you question is Yes. -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2014-10-27 20:18 -0400 |
| Message-ID | <mailman.15246.1414455546.18130.python-list@python.org> |
| In reply to | #79788 |
On Mon, 27 Oct 2014 08:10:04 -0700 (PDT), emmanueloje@gmail.com declaimed
the following:
>Write a program that reads the contents of the two files into two separate lists. The user should be able to enter a boy's name, a girl's name or both, and the application will display messages indicating whether the names were among the most popular.
Define what is meant by "among the most popular"... Does that just mean
the entered name appears in one of the lists you provided? Does it mean the
name appears near the top of the list (which presumes the lists are in
descending popularity)? Does it mean you have to count how many times a
name shows up in the list first, to determine popularity (I'm not going to
go through them to see if there are duplicates).
Further consultation will be at US$100/hour of my time. All code
remains copyright to me, and copyright disclaimers must be kept in the
code.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2014-10-28 00:20 +0000 |
| Message-ID | <m2mnfl$hvh$1@dont-email.me> |
| In reply to | #79788 |
On Mon, 27 Oct 2014 08:10:04 -0700, emmanueloje wrote: > Write a program that reads the contents of the two files into two > separate lists. Yep, know how to do that > The user should be able to enter a boy's name, a girl's > name or both Yep, know how to do that > and the application will display messages > indicating whether the names were among the most popular. Nope, not sure how to do that, please define the algorithm for determining a "most popular name" Determining if the name is in either of the lists is easy, know how to do that, but I'm not sure from your problem description if that's your definition of a "most popular name" or not. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2014-10-28 10:33 +1000 |
| Message-ID | <m2mo7s$ofh$1@dont-email.me> |
| In reply to | #79788 |
On 28/10/2014 1:10 AM, emmanueloje@gmail.com wrote: > Write a program that reads the contents of the two files into two separate lists. The user should be able to enter a boy's name, a girl's name or both, and the application will display messages indicating whether the names were among the most popular. This is actually a trick question. This is a classic unsolvable problem in computer science, known as the Dual Baskets problem. It is NP-complete, meaning that there is no easy solution. It requires brute-forcing and can take an indefinite period of time to complete, if at all. The correct answer is "Not possible".
[toc] | [prev] | [next] | [standalone]
| From | Anton <anton.schattenfeld@gmail.com> |
|---|---|
| Date | 2014-10-28 18:28 -0700 |
| Message-ID | <9b5151e5-9a8c-449c-9164-98bc908b887d@googlegroups.com> |
| In reply to | #79812 |
On Monday, October 27, 2014 5:33:17 PM UTC-7, alex23 wrote: > On 28/10/2014 1:10 AM, em..@gmail.com wrote: > > Write a program that reads the contents of the two files into two separate lists. The user should be able to enter a boy's name, a girl's name or both, and the application will display messages indicating whether the names were among the most popular. > > This is actually a trick question. This is a classic unsolvable problem > in computer science, known as the Dual Baskets problem. It is > NP-complete, meaning that there is no easy solution. It requires > brute-forcing and can take an indefinite period of time to complete, if > at all. > > The correct answer is "Not possible". Can you elaborate why it is an NP-complete problem or maybe a link to description of problem you are referring to? Thanks.
[toc] | [prev] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2014-10-29 12:03 +1000 |
| Message-ID | <m2pht4$sq7$1@dont-email.me> |
| In reply to | #79864 |
On 29/10/2014 11:28 AM, Anton wrote: > Can you elaborate why it is an NP-complete problem or maybe a link to description of problem you are referring to? While not the exact problem, it's tangentially related to: http://kenlevine.blogspot.com.au/2011/03/reducing-humor-to-equation.html
[toc] | [prev] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2014-10-29 18:13 +1300 |
| Message-ID | <cbbbasFi3o9U1@mid.individual.net> |
| In reply to | #79864 |
> On Monday, October 27, 2014 5:33:17 PM UTC-7, alex23 wrote: > >>It is NP-complete, meaning that there is no easy solution. >> >>The correct answer is "Not possible". No, that's not the correct answer. Being NP-complete doesn't mean something is impossible, or even hard to do. All it means is that nobody knows of a cleverer solution than just trying all possibilities. That's only a difficulty if the problem is large enough; often it won't be. -- Greg
[toc] | [prev] | [next] | [standalone]
| From | Anton <anton.schattenfeld@gmail.com> |
|---|---|
| Date | 2014-10-29 17:09 -0700 |
| Message-ID | <8df8501c-f89b-44a5-8296-b491bf08f44c@googlegroups.com> |
| In reply to | #79882 |
On Tuesday, October 28, 2014 10:13:14 PM UTC-7, Gregory Ewing wrote: > No, that's not the correct answer. Being NP-complete doesn't > mean something is impossible, or even hard to do. All it > means is that nobody knows of a cleverer solution than > just trying all possibilities. That's only a difficulty if > the problem is large enough; often it won't be. Why do you need to iterate over all possibilities solving this problem anyway?
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-10-28 00:24 -0400 |
| Message-ID | <mailman.15251.1414470264.18130.python-list@python.org> |
| In reply to | #79788 |
On 10/27/2014 11:10 AM, emmanueloje@gmail.com wrote: > THIS IS THE LIST OF BOY NAMES > Jacob > ... Writing hundreds of unnecessary lines at minimum inconsiderate. Please don't do it. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | "Mario R. Osorio" <nimbiotics@gmail.com> |
|---|---|
| Date | 2014-10-28 08:38 -0700 |
| Message-ID | <cd80feed-eff7-46cd-aa67-821161f36a4f@googlegroups.com> |
| In reply to | #79822 |
On Tuesday, October 28, 2014 12:25:13 AM UTC-4, Terry Reedy wrote: > On 10/27/2014 11:10 AM, emmanueloje@gmail.com wrote: > > > THIS IS THE LIST OF BOY NAMES > > Jacob > > ... > > Writing hundreds of unnecessary lines at minimum inconsiderate. Please > don't do it. > > -- > Terry Jan Reedy The python programming community is BY FAR the best I've been in touch with. Asking for help with some code that is not working is OK here, but asking to have the homework done is disgusting. Just try mentioning the word homework on c++ or javascrip groups: They'll bully you to death!
[toc] | [prev] | [next] | [standalone]
| From | ngangsia akumbo <ngangsia@gmail.com> |
|---|---|
| Date | 2014-10-28 09:07 -0700 |
| Message-ID | <f9c39375-d0ff-4f16-aa05-6d8c8fdf7267@googlegroups.com> |
| In reply to | #79788 |
This is a sample code on how to read data from a file
files1 {}
result = open("file1.txt")
for line in result:
file1 = line>split()
files1.append(file1)
result.close()
file1.sort()
file1.reverse()
print('THE FILE INFO')
print(file1(0)
print(file1(1)
[toc] | [prev] | [next] | [standalone]
| From | Cameron Simpson <cs@zip.com.au> |
|---|---|
| Date | 2014-10-29 11:53 +1100 |
| Message-ID | <mailman.15274.1414544041.18130.python-list@python.org> |
| In reply to | #79846 |
On 28Oct2014 09:07, ngangsia akumbo <ngangsia@gmail.com> wrote:
>This is a sample code on how to read data from a file
>
>files1 {}
>
>result = open("file1.txt")
>for line in result:
> file1 = line>split()
>files1.append(file1)
>result.close()
>file1.sort()
>file1.reverse()
>
>print('THE FILE INFO')
>
>print(file1(0)
>print(file1(1)
Do you have a specific question to accompany this?
The code above is syntactly invalid, so it will not run.
The line:
files1 {}
is invalid, but looks like it is intended to initialise files1 as a dictionary.
However, the rest of the program seems to use it as though it were a list.
The line:
file1 = line>split()
should probably be written:
file1 = line.split()
With ">" it is legal (as it performs a comparison) but will fail because
there's no bare "split()" function, and anyway is probably not as intended.
Your final print statements need an extra closing parenthesis each.
Cheers,
Cameron Simpson <cs@zip.com.au>
I fit in my suit, my suit fits in my suitcase, hence i fit in my suitcase.
- Cees Keyer <cees@htsa.hva.nl>
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2014-10-28 22:11 -0400 |
| Message-ID | <mailman.15277.1414548479.18130.python-list@python.org> |
| In reply to | #79846 |
Cameron Simpson <cs@zip.com.au> Wrote in message:
> On 28Oct2014 09:07, ngangsia akumbo <ngangsia@gmail.com> wrote:
>>This is a sample code on how to read data from a file
>>
>>files1 {}
>>
>>result = open("file1.txt")
>>for line in result:
>> file1 = line>split()
>>files1.append(file1)
>>result.close()
>>file1.sort()
>>file1.reverse()
>>
>>print('THE FILE INFO')
>>
>>print(file1(0)
>>print(file1(1)
>
> Do you have a specific question to accompany this?
>
> The code above is syntactly invalid, so it will not run.
>
> ....
>
> Your final print statements need an extra closing parenthesis each.
>
>
Other comments -
The line that appends probably wants to be in the loop, and is not.
Is there a reason you're subsequently processing only the last line?
--
DaveA
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2014-10-29 18:03 +0000 |
| Message-ID | <m2ra5l$12h$2@dont-email.me> |
| In reply to | #79788 |
On Mon, 27 Oct 2014 08:10:04 -0700, emmanueloje wrote: > Write a program ... Hey dudester I coded a solution for you, you can get it here: http://www.sined.co.uk/tmp/names.py.txt Make sure you leave all the comments in so your instructor realises how much effort you went in to in researching how to code this. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web