Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56407
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <robertkday@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | UNSURE 0.222 |
| X-Spam-Level | ** |
| X-Spam-Evidence | '*H*': 0.56; '*S*': 0.00; "'c',": 0.16; "'o',": 0.16; 'ord': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'result.': 0.19; 'header :User-Agent:1': 0.23; '(or': 0.24; 'define': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'fixed': 0.29; 'converting': 0.30; 'mod': 0.31; 'subject:numbers': 0.31; '(i.e.': 0.33; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'done': 0.36; 'should': 0.36; 'example,': 0.37; 'expected': 0.38; 'message-id:@gmail.com': 0.38; 'mapping': 0.38; 'to:addr :python-list': 0.38; 'that,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'letters': 0.60; 'numbers': 0.61; 'back': 0.62; "you've": 0.63; 'email addr:gmail.com': 0.63; 'sum': 0.64; 'between': 0.67; '26,': 0.68; 'capital': 0.73; 'presumably': 0.84; 'tricky': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=O2RvU/ANxBWfPQEIPmSi/iRPuoY5NiUu3tCUjiglHOY=; b=GgLahBjZOtjp5i2FQK4H6Bq2To13MqXT0Ylf1KE9cPLUWIicdsfsl+JnPnG9202ozn Jcy64E0YXEH/f7qP597zDhJl1tdzEZ/Suknco9wxf3FTOQiZ5gChWwYOsit+9gU3Lfst 3jZd1vx5KkraPyuTJytY++KswV/7cSxkLDX7NWfJysVy9YFr2b7s7oayy1qZGaoIpTug 2iH0LXUExe5sPAJSYUbDHQ3amG43lboon0WpCI6zjXZcqPpH8lhYgjZzxypLqVOOSkIk 8Xjyslvc/vFt4j4wA37aamKdJqc5MR7qxiWRe40Q5eY4P1oB0fi5aD9wI2tZZcl/CPRM jfHg== |
| X-Received | by 10.152.120.5 with SMTP id ky5mr1719038lab.18.1381243661482; Tue, 08 Oct 2013 07:47:41 -0700 (PDT) |
| Date | Tue, 08 Oct 2013 15:47:39 +0100 |
| From | Robert Day <robertkday@gmail.com> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: converting letters to numbers |
| References | <26151b64-4f5e-4ee9-81ac-26679932f43d@googlegroups.com> |
| In-Reply-To | <26151b64-4f5e-4ee9-81ac-26679932f43d@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Mailman-Approved-At | Tue, 08 Oct 2013 16:48:19 +0200 |
| 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 | <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.856.1381243701.18130.python-list@python.org> (permalink) |
| Lines | 12 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1381243701 news.xs4all.nl 15937 [2001:888:2000:d::a6]:37067 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:56407 |
Show key headers only | View raw
On 08/10/13 15:28, kjakupak@gmail.com wrote:
> I have to define a function add(c1, c2), where c1 and c2 are capital letters; the return value should be the sum (obtained by converting the letters to numbers, adding mod 26, then converting back to a capital letter).
>
Can you give some expected outputs? For example, add('A', 'B') should
presumably return 'C', and add('M', 'B') should presumably return 'O',
but what about add('A', 'A') or add('Z', 'Z')?
It feels like the only tricky bit is mapping letters to numbers (i.e.
does A equal 1 or 0?), which you'd do by subtracting a fixed value from
the result of chr. Once you've done that, you'd do the arithmetic to get
a number between 1 and 26 (or 0 and 25), then add the same fixed value
to that and call ord on the result.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
converting letters to numbers kjakupak@gmail.com - 2013-10-08 07:28 -0700
Re: converting letters to numbers Robert Day <robertkday@gmail.com> - 2013-10-08 15:47 +0100
Re: converting letters to numbers kjakupak@gmail.com - 2013-10-08 07:51 -0700
Re: converting letters to numbers Joel Goldstick <joel.goldstick@gmail.com> - 2013-10-08 11:01 -0400
Re: converting letters to numbers random832@fastmail.us - 2013-10-08 11:36 -0400
Re: converting letters to numbers kjakupak@gmail.com - 2013-10-08 08:44 -0700
Re: converting letters to numbers random832@fastmail.us - 2013-10-08 11:58 -0400
Re: converting letters to numbers Tim Roberts <timr@probo.com> - 2013-10-13 20:13 -0700
Re: converting letters to numbers Steven D'Aprano <steve@pearwood.info> - 2013-10-14 05:02 +0000
Re: converting letters to numbers Charles Hixson <charleshixsn@earthlink.net> - 2013-10-16 12:18 -0700
Re: converting letters to numbers Piet van Oostrum <piet@vanoostrum.org> - 2013-10-16 16:25 -0400
Re: converting letters to numbers Rotwang <sg552@hotmail.co.uk> - 2013-10-16 23:39 +0100
Re: converting letters to numbers MRAB <python@mrabarnett.plus.com> - 2013-10-16 23:53 +0100
Re: converting letters to numbers Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-17 01:21 +0100
Re: converting letters to numbers Tim Roberts <timr@probo.com> - 2013-10-19 16:31 -0700
Re: converting letters to numbers rusi <rustompmody@gmail.com> - 2013-10-20 01:33 -0700
Re: converting letters to numbers Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-08 17:05 +0100
Re: converting letters to numbers Dave Angel <davea@davea.name> - 2013-10-08 21:24 +0000
csiph-web