Discussion:
in Python: (101 102 103 201 202 203 301 302 303 401 402 403 )
(too old to reply)
HenHanna
2024-06-09 23:42:02 UTC
Permalink
# (101 102 103 201 202 203 301 302 303 401 402 403 )


print( [ x+i for x in range(100,401,100) for i in range(1,4) ] )


is there another (simple) way to write this?
Paul Rubin
2024-06-10 04:18:25 UTC
Permalink
Post by HenHanna
is there another (simple) way to write this?
Yes, but please consider doing these easy exercises yourself instead of
fobbing them onto other people.
Phil Carmody
2024-06-13 12:01:32 UTC
Permalink
Post by Paul Rubin
Post by HenHanna
is there another (simple) way to write this?
Yes, but please consider doing these easy exercises yourself instead of
fobbing them onto other people.
Hen's probably just an experimental GPT. You, with your limited
resources, can never train it.

I'd say you can't beat the verbosity, or lack thereof of just plain zsh/bash:
$ echo {1,2,3,4}0{1,2,3}
101 102 103 201 202 203 301 302 303 401 402 403

Phil
--
We are no longer hunters and nomads. No longer awed and frightened, as we have
gained some understanding of the world in which we live. As such, we can cast
aside childish remnants from the dawn of our civilization.
-- NotSanguine on SoylentNews, after Eugen Weber in /The Western Tradition/
candycanearter07
2024-06-14 06:10:06 UTC
Permalink
Post by Phil Carmody
Post by Paul Rubin
Post by HenHanna
is there another (simple) way to write this?
Yes, but please consider doing these easy exercises yourself instead of
fobbing them onto other people.
Hen's probably just an experimental GPT. You, with your limited
resources, can never train it.
$ echo {1,2,3,4}0{1,2,3}
101 102 103 201 202 203 301 302 303 401 402 403
Phil
I /think/ you can replace it with {1...4} and {1...3}? I know there is
some syntax for "range of numbers" but I can't remember it exactly.
--
user <candycane> is generated from /dev/urandom
Lawrence D'Oliveiro
2024-06-14 07:18:49 UTC
Permalink
Post by candycanearter07
I /think/ you can replace it with {1...4} and {1...3}?
Two dots, not three. Bash extension.
Peter J. Holzer
2024-06-18 21:26:50 UTC
Permalink
Post by candycanearter07
Post by Phil Carmody
$ echo {1,2,3,4}0{1,2,3}
101 102 103 201 202 203 301 302 303 401 402 403
I /think/ you can replace it with {1...4} and {1...3}? I know there is
some syntax for "range of numbers" but I can't remember it exactly.
Only two dots, not three:

% echo {1..4}0{1..3}
101 102 103 201 202 203 301 302 303 401 402 403

hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | ***@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Phil Carmody
2024-06-20 14:20:20 UTC
Permalink
Post by candycanearter07
Post by Phil Carmody
Post by Paul Rubin
Post by HenHanna
is there another (simple) way to write this?
Yes, but please consider doing these easy exercises yourself
instead of
fobbing them onto other people.
Hen's probably just an experimental GPT. You, with your limited
resources, can never train it.
$ echo {1,2,3,4}0{1,2,3}
101 102 103 201 202 203 301 302 303 401 402 403
I /think/ you can replace it with {1...4} and {1...3}? I know there is
some syntax for "range of numbers" but I can't remember it exactly.
You're right, but it's even shorter -
$ echo {1..4}0{1..3}
101 102 103 201 202 203 301 302 303 401 402 403

Good golfing!

Phil
--
We are no longer hunters and nomads. No longer awed and frightened, as we have
gained some understanding of the world in which we live. As such, we can cast
aside childish remnants from the dawn of our civilization.
-- NotSanguine on SoylentNews, after Eugen Weber in /The Western Tradition/
candycanearter07
2024-06-21 06:10:04 UTC
Permalink
Post by Phil Carmody
Post by candycanearter07
Post by Phil Carmody
Post by Paul Rubin
Post by HenHanna
is there another (simple) way to write this?
Yes, but please consider doing these easy exercises yourself instead of
fobbing them onto other people.
Hen's probably just an experimental GPT. You, with your limited
resources, can never train it.
$ echo {1,2,3,4}0{1,2,3}
101 102 103 201 202 203 301 302 303 401 402 403
I /think/ you can replace it with {1...4} and {1...3}? I know there is
some syntax for "range of numbers" but I can't remember it exactly.
You're right, but it's even shorter -
$ echo {1..4}0{1..3}
101 102 103 201 202 203 301 302 303 401 402 403
Good golfing!
Phil
Thanks :D
--
user <candycane> is generated from /dev/urandom
Loading...