Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #197133
| Path | csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Kaz Kylheku <643-408-1753@kylheku.com> |
| Newsgroups | rec.puzzles, comp.lang.lisp, comp.lang.python |
| Subject | Re: Add the numbers in a 9x9 multiplication Table |
| Date | Thu, 2 Jan 2025 05:49:18 -0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 45 |
| Message-ID | <20250101214422.224@kylheku.com> (permalink) |
| References | <0b09b939cdbbe465809a7ec27e30912a@www.novabbs.com> |
| Injection-Date | Thu, 02 Jan 2025 06:49:23 +0100 (CET) |
| Injection-Info | dont-email.me; posting-host="083db82202383aa73ae8305bddd678d4"; logging-data="3377365"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/VOPA8yQjzvbhhh0mF0ykkSt9xBSrdPYM=" |
| User-Agent | slrn/pre1.0.4-9 (Linux) |
| Cancel-Lock | sha1:WEpu17uHHCechZc0cD42uNjKsL8= |
| Xref | csiph.com rec.puzzles:26394 comp.lang.lisp:60215 comp.lang.python:197133 |
Cross-posted to 3 groups.
Show key headers only | View raw
On 2025-01-02, HenHanna <HenHanna@dev.null> wrote:
> Pls give (show) me nice variations in Lisp and Python. Thanks!!!
>
>
>
> A happy new year! ...
>
> 44 x 44 = 1936
> 45 x 45 = 2025 <-- one reason that Puzzle nerds are excited today.
> 46 x 46 = 2116
>
>
> _______________________________________
> The following (in Lisp (Scheme) and Python) adds
> all the numbers in a 9x9 multiplication Table.
> ________________________________
> (print (apply +
> (apply append
> (map (lambda (y)
> (map (lambda (x) (* x y)) (iota 9 1)))
> (iota 9 1)))))
> ______________________________________
> isum=0
> for y in range(1, 10):
> print()
> for x in range(1, 10):
> print(f"{x*y:3}", end=" ")
> isum += x*y
> print(' Total= ', isum, '\n')
> _______________________________
> kuku = [i*j for i in range(1, 10) for j in range(1, 10)]
> print(sum(kuku))
This is the TXR Lisp interactive listener of TXR 297.
Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
Allow me to expand a bit more on why there is no substitute for macros.
1> (sum-each ((i 1..10) (j 1..10)) (* i j))
285
2> (sum-each-prod ((i 1..10) (j 1..10)) (* i j))
2025
--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
Add the numbers in a 9x9 multiplication Table HenHanna <HenHanna@dev.null> - 2025-01-02 04:02 +0000
Re: Add the numbers in a 9x9 multiplication Table Kaz Kylheku <643-408-1753@kylheku.com> - 2025-01-02 05:49 +0000
Re: Add the numbers in a 9x9 multiplication Table "B. Pym" <Nobody447095@here-nor-there.org> - 2025-06-06 00:13 +0000
Re: Add the numbers in a 9x9 multiplication Table "B. Pym" <Nobody447095@here-nor-there.org> - 2025-06-06 15:25 +0000
Re: Add the numbers in a 9x9 multiplication Table yeti <yeti@tilde.institute> - 2025-01-02 11:36 +0042
Re: Add the numbers in a 9x9 multiplication Table HenHanna <HenHanna@dev.null> - 2025-01-03 21:31 +0000
Re: Add the numbers in a 9x9 multiplication Table Kaz Kylheku <643-408-1753@kylheku.com> - 2025-01-03 23:12 +0000
csiph-web