Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: totally lost newbie

Thread Tools

Re: totally lost newbie

Steve Howell
Posts: n/a

--- mark <(E-Mail Removed)> wrote:

> Hi all
> I posted earlier on this but have changed my
> approach so here is my
> latest attempt at solving a problem. I have been
> working on this for
> around 12 hours straight and am still struggling
> with it.
> Write a program that reads the values for a random
> list of cards from
> a file, where each line in the file specifies a
> single card with the
> rank and then the suit separated by a space. The
> rank should be an
> integer in the range of 1 to 13 (Ace:1, King:13),
> while the suit
> should be a lower case character in the set { 'h',
> 'd', 'c', 's' }.
> Sort the card entries into suits ordered by rank,
> and print out the
> ordered list. Hint: sort the list first by rank, and
> then by suit.

Given that the hint is to sort twice, you can first
break down the problem by just trying to sort your
list according to the number on the card, and don't
worry about the suit. Also, try using a data file
that doesn't have any face cards in it, to keep things
simple at first.

Then, to get the face cards working, think about
this--a Jack is really just an 11, a Queen is just a
12, a King is just a 13, and an Ace is just a 1.

When you read in your data, maybe you want to just
work with the numbers internally? Do you know how to
use a dictionary to map K to 13?

Then, when it comes time to produce the final output,
you'll need to map 13 back to 'K', which again
involves using a dictionary.

There are other approaches, too, just hope this sparks
some thought.

__________________________________________________ __________________________________Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: totally lost newbie Steve Howell Python 1 05-27-2007 02:42 PM
totally lost newbie mark Python 3 05-27-2007 10:58 AM
Update SQL database from form - newbie and totally lost! guardsman85 ASP .Net 2 08-29-2006 03:08 AM
stl errors - totally lost karthik kumar C++ 8 12-03-2004 01:33 PM
my button died and I'm totally lost Steve ASP .Net 10 01-13-2004 04:03 PM