List *all* the tuples! Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The PPCG Site design is on its way - help us make it awesome! Sandbox for Proposed ChallengesOutput a list of all rational numbersMoore IterationNaturally linear Diophantine equationsCo-primality and the number piRotate every row and column in a matrixConvert header levels to numbersASCII DandelionsPrint all decimalsParse a list of lists into a Sad-List2D Array Middle Point
cpython3 different behavior between running a file line by line in interpreter mode and "python3 file"
List numbering with letters
Does polymorph use a PC’s CR or its level?
Area of a 2D convex hull
List *all* the tuples!
The logistics of corpse disposal
When -s is used with third person singular. What's its use in this context?
Create Pages from Database
If A makes B more likely then B makes A more likely"
Could transporting electricity using plastic water pipes be feasible?
Bold symbols in LuaLaTeX with setmathfont
He is picky about food(,) so he only eats what he likes
macOS-like app switching in Plasma 5
When to stop saving and start investing?
Regex in IF condition in awk
What's the purpose of writing one's academic bio in 3rd person?
Are variable time comparisons always a security risk in cryptography code?
How to change the Selenium IDE file extension (.side file into java file) while saving the project
Stirling numbers of second kind, but no two adjacent numbers in same part.
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
Is there a concise way to say "all of the X, one of each"?
Double integral with logarithms
Project this triangle on surface of a sphere
Bonus calculation: Am I making a mountain out of a molehill?
List *all* the tuples!
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The PPCG Site design is on its way - help us make it awesome!
Sandbox for Proposed ChallengesOutput a list of all rational numbersMoore IterationNaturally linear Diophantine equationsCo-primality and the number piRotate every row and column in a matrixConvert header levels to numbersASCII DandelionsPrint all decimalsParse a list of lists into a Sad-List2D Array Middle Point
$begingroup$
Write a program, given an input n, will generate all possible n-tuples using natural numbers.
n=1
(1),(2),(3),(4),(5),(6)...
n=2
(1,1),(1,2),(2,1),(2,2),(1,3),(3,1),(2,3),(3,2),(3,3)...
n=6
(1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1)...
- The output may be in any order that does not break any other rules.
- The program must be written to run forever and list all applicable tuples exactly once, in theory.
- In reality, your program will reach your integer type's limit and crash. This is acceptable as long the program would run infinitely long if only your integer type was unlimited.
- Each valid tuple must be listed within finite time, if only the program were allowed to run that long.
- The output may, at your option, include zeroes in addition to the natural numbers.
- You may choose your program's output format for your convenience, as long as the separation between tuples and numbers inside each tuple is clear and consistent. (For example, one tuple per line.)
- Code-golf rules apply, shortest program wins.
Thanks to "Artemis Fowl" for feedback during the sandbox phase.
code-golf sequence
$endgroup$
add a comment |
$begingroup$
Write a program, given an input n, will generate all possible n-tuples using natural numbers.
n=1
(1),(2),(3),(4),(5),(6)...
n=2
(1,1),(1,2),(2,1),(2,2),(1,3),(3,1),(2,3),(3,2),(3,3)...
n=6
(1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1)...
- The output may be in any order that does not break any other rules.
- The program must be written to run forever and list all applicable tuples exactly once, in theory.
- In reality, your program will reach your integer type's limit and crash. This is acceptable as long the program would run infinitely long if only your integer type was unlimited.
- Each valid tuple must be listed within finite time, if only the program were allowed to run that long.
- The output may, at your option, include zeroes in addition to the natural numbers.
- You may choose your program's output format for your convenience, as long as the separation between tuples and numbers inside each tuple is clear and consistent. (For example, one tuple per line.)
- Code-golf rules apply, shortest program wins.
Thanks to "Artemis Fowl" for feedback during the sandbox phase.
code-golf sequence
$endgroup$
$begingroup$
For n=6, is it acceptable to produce 0,0 .. 5,5 or does it have to include 6,6?
$endgroup$
– Phil H
3 hours ago
$begingroup$
For n=6, the 6-tuples are (1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1) etc. I'll add this to the the examples.
$endgroup$
– billpg
3 hours ago
1
$begingroup$
Each valid tuple must be listed within finite time, if only the program were allowed to run that long. .. Does this contradict the output being in any order? i.e what if my order is (1,1),(2,1),(3,1)...(n,1) and only once I've gone through every natural number will i print (1,2)
$endgroup$
– Expired Data
3 hours ago
$begingroup$
Fair point, I'll edit the rule.
$endgroup$
– billpg
3 hours ago
$begingroup$
I assume it is valid if when the program crashes it produces some extraneous output in addition to the tuples printed so far, right?
$endgroup$
– Luis Mendo
35 mins ago
add a comment |
$begingroup$
Write a program, given an input n, will generate all possible n-tuples using natural numbers.
n=1
(1),(2),(3),(4),(5),(6)...
n=2
(1,1),(1,2),(2,1),(2,2),(1,3),(3,1),(2,3),(3,2),(3,3)...
n=6
(1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1)...
- The output may be in any order that does not break any other rules.
- The program must be written to run forever and list all applicable tuples exactly once, in theory.
- In reality, your program will reach your integer type's limit and crash. This is acceptable as long the program would run infinitely long if only your integer type was unlimited.
- Each valid tuple must be listed within finite time, if only the program were allowed to run that long.
- The output may, at your option, include zeroes in addition to the natural numbers.
- You may choose your program's output format for your convenience, as long as the separation between tuples and numbers inside each tuple is clear and consistent. (For example, one tuple per line.)
- Code-golf rules apply, shortest program wins.
Thanks to "Artemis Fowl" for feedback during the sandbox phase.
code-golf sequence
$endgroup$
Write a program, given an input n, will generate all possible n-tuples using natural numbers.
n=1
(1),(2),(3),(4),(5),(6)...
n=2
(1,1),(1,2),(2,1),(2,2),(1,3),(3,1),(2,3),(3,2),(3,3)...
n=6
(1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1)...
- The output may be in any order that does not break any other rules.
- The program must be written to run forever and list all applicable tuples exactly once, in theory.
- In reality, your program will reach your integer type's limit and crash. This is acceptable as long the program would run infinitely long if only your integer type was unlimited.
- Each valid tuple must be listed within finite time, if only the program were allowed to run that long.
- The output may, at your option, include zeroes in addition to the natural numbers.
- You may choose your program's output format for your convenience, as long as the separation between tuples and numbers inside each tuple is clear and consistent. (For example, one tuple per line.)
- Code-golf rules apply, shortest program wins.
Thanks to "Artemis Fowl" for feedback during the sandbox phase.
code-golf sequence
code-golf sequence
edited 3 hours ago
billpg
asked 3 hours ago
billpgbillpg
9451929
9451929
$begingroup$
For n=6, is it acceptable to produce 0,0 .. 5,5 or does it have to include 6,6?
$endgroup$
– Phil H
3 hours ago
$begingroup$
For n=6, the 6-tuples are (1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1) etc. I'll add this to the the examples.
$endgroup$
– billpg
3 hours ago
1
$begingroup$
Each valid tuple must be listed within finite time, if only the program were allowed to run that long. .. Does this contradict the output being in any order? i.e what if my order is (1,1),(2,1),(3,1)...(n,1) and only once I've gone through every natural number will i print (1,2)
$endgroup$
– Expired Data
3 hours ago
$begingroup$
Fair point, I'll edit the rule.
$endgroup$
– billpg
3 hours ago
$begingroup$
I assume it is valid if when the program crashes it produces some extraneous output in addition to the tuples printed so far, right?
$endgroup$
– Luis Mendo
35 mins ago
add a comment |
$begingroup$
For n=6, is it acceptable to produce 0,0 .. 5,5 or does it have to include 6,6?
$endgroup$
– Phil H
3 hours ago
$begingroup$
For n=6, the 6-tuples are (1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1) etc. I'll add this to the the examples.
$endgroup$
– billpg
3 hours ago
1
$begingroup$
Each valid tuple must be listed within finite time, if only the program were allowed to run that long. .. Does this contradict the output being in any order? i.e what if my order is (1,1),(2,1),(3,1)...(n,1) and only once I've gone through every natural number will i print (1,2)
$endgroup$
– Expired Data
3 hours ago
$begingroup$
Fair point, I'll edit the rule.
$endgroup$
– billpg
3 hours ago
$begingroup$
I assume it is valid if when the program crashes it produces some extraneous output in addition to the tuples printed so far, right?
$endgroup$
– Luis Mendo
35 mins ago
$begingroup$
For n=6, is it acceptable to produce 0,0 .. 5,5 or does it have to include 6,6?
$endgroup$
– Phil H
3 hours ago
$begingroup$
For n=6, is it acceptable to produce 0,0 .. 5,5 or does it have to include 6,6?
$endgroup$
– Phil H
3 hours ago
$begingroup$
For n=6, the 6-tuples are (1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1) etc. I'll add this to the the examples.
$endgroup$
– billpg
3 hours ago
$begingroup$
For n=6, the 6-tuples are (1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1) etc. I'll add this to the the examples.
$endgroup$
– billpg
3 hours ago
1
1
$begingroup$
Each valid tuple must be listed within finite time, if only the program were allowed to run that long. .. Does this contradict the output being in any order? i.e what if my order is (1,1),(2,1),(3,1)...(n,1) and only once I've gone through every natural number will i print (1,2)
$endgroup$
– Expired Data
3 hours ago
$begingroup$
Each valid tuple must be listed within finite time, if only the program were allowed to run that long. .. Does this contradict the output being in any order? i.e what if my order is (1,1),(2,1),(3,1)...(n,1) and only once I've gone through every natural number will i print (1,2)
$endgroup$
– Expired Data
3 hours ago
$begingroup$
Fair point, I'll edit the rule.
$endgroup$
– billpg
3 hours ago
$begingroup$
Fair point, I'll edit the rule.
$endgroup$
– billpg
3 hours ago
$begingroup$
I assume it is valid if when the program crashes it produces some extraneous output in addition to the tuples printed so far, right?
$endgroup$
– Luis Mendo
35 mins ago
$begingroup$
I assume it is valid if when the program crashes it produces some extraneous output in addition to the tuples printed so far, right?
$endgroup$
– Luis Mendo
35 mins ago
add a comment |
4 Answers
4
active
oldest
votes
$begingroup$
Haskell, 62 bytes
([1..]>>=).(!)
0!s=[[]|s<1]
n!s=[a:p|a<-[1..s],p<-(n-1)!(s-a)]
Try it online!
n!s generates all the n-tuples that sum to s.
Then the answer is ([1..]>>=).(!), i.e. n -> [t | s<-[1..], t<-n!s].
This is a function mapping an integer n to an infinite lazy list of tuples (lists of integers).
$endgroup$
add a comment |
$begingroup$
Perl 6, 37 bytes
$++.polymod(1+$++ xx $_-1).say xx *
Try it online!
Essentially runs polymod with as many entries as needed, where the modulo is always greater than the input, i.e. 0.polymod( 1,1,1 ), 1.polymod( 2,2,2 ) etc. That way the digit is always within the range. Perl6 won't let me modulo infinity...
$endgroup$
add a comment |
$begingroup$
VDM-SL, 51 bytes
g(i)==if i=0thenelsex:nat,y in set g(i-1)
Recursive set comprehension with sequence concatenation..
Not on TIO, you could run in a program (if you turn on limits for nat type or it wont terminate):
functions
g:nat->set of ?
g(i)==if i=0thenelsex:nat,y in set g(i-1)
Includes the optional 0s in answer otherwise it would be 52 bytes binding on nat1
$endgroup$
add a comment |
$begingroup$
05AB1E, 15 bytes
<[>DÅœIùvyœÙvy,
Inspired by @Lynn's Haskell answer.
Try it online.
Explanation:
< # Decrease the (implicit) input-integer by 1
[ # Start an infinite loop:
> # Increase the integer at the top of the stack by 1
D # And duplicate it (for the next iteration)
Ŝ # Create lists of national integers that sum to this integer
Iù # Only leave the lists of a size equal to the input
v # Loop over each list `y` in this list of lists:
yœÙ # Get all possible unique permutations of this list `y`
v # Inner loop over each list `y` in this list of unique permutation lists:
y, # And output this list `y` with a trailing newline
$endgroup$
1
$begingroup$
When will the program get to [1,2,1]? Remember it has to be within finite time.
$endgroup$
– billpg
3 hours ago
$begingroup$
@billpg Should be fixed now.
$endgroup$
– Kevin Cruijssen
1 hour ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "200"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f183225%2flist-all-the-tuples%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Haskell, 62 bytes
([1..]>>=).(!)
0!s=[[]|s<1]
n!s=[a:p|a<-[1..s],p<-(n-1)!(s-a)]
Try it online!
n!s generates all the n-tuples that sum to s.
Then the answer is ([1..]>>=).(!), i.e. n -> [t | s<-[1..], t<-n!s].
This is a function mapping an integer n to an infinite lazy list of tuples (lists of integers).
$endgroup$
add a comment |
$begingroup$
Haskell, 62 bytes
([1..]>>=).(!)
0!s=[[]|s<1]
n!s=[a:p|a<-[1..s],p<-(n-1)!(s-a)]
Try it online!
n!s generates all the n-tuples that sum to s.
Then the answer is ([1..]>>=).(!), i.e. n -> [t | s<-[1..], t<-n!s].
This is a function mapping an integer n to an infinite lazy list of tuples (lists of integers).
$endgroup$
add a comment |
$begingroup$
Haskell, 62 bytes
([1..]>>=).(!)
0!s=[[]|s<1]
n!s=[a:p|a<-[1..s],p<-(n-1)!(s-a)]
Try it online!
n!s generates all the n-tuples that sum to s.
Then the answer is ([1..]>>=).(!), i.e. n -> [t | s<-[1..], t<-n!s].
This is a function mapping an integer n to an infinite lazy list of tuples (lists of integers).
$endgroup$
Haskell, 62 bytes
([1..]>>=).(!)
0!s=[[]|s<1]
n!s=[a:p|a<-[1..s],p<-(n-1)!(s-a)]
Try it online!
n!s generates all the n-tuples that sum to s.
Then the answer is ([1..]>>=).(!), i.e. n -> [t | s<-[1..], t<-n!s].
This is a function mapping an integer n to an infinite lazy list of tuples (lists of integers).
answered 3 hours ago
LynnLynn
50.9k899233
50.9k899233
add a comment |
add a comment |
$begingroup$
Perl 6, 37 bytes
$++.polymod(1+$++ xx $_-1).say xx *
Try it online!
Essentially runs polymod with as many entries as needed, where the modulo is always greater than the input, i.e. 0.polymod( 1,1,1 ), 1.polymod( 2,2,2 ) etc. That way the digit is always within the range. Perl6 won't let me modulo infinity...
$endgroup$
add a comment |
$begingroup$
Perl 6, 37 bytes
$++.polymod(1+$++ xx $_-1).say xx *
Try it online!
Essentially runs polymod with as many entries as needed, where the modulo is always greater than the input, i.e. 0.polymod( 1,1,1 ), 1.polymod( 2,2,2 ) etc. That way the digit is always within the range. Perl6 won't let me modulo infinity...
$endgroup$
add a comment |
$begingroup$
Perl 6, 37 bytes
$++.polymod(1+$++ xx $_-1).say xx *
Try it online!
Essentially runs polymod with as many entries as needed, where the modulo is always greater than the input, i.e. 0.polymod( 1,1,1 ), 1.polymod( 2,2,2 ) etc. That way the digit is always within the range. Perl6 won't let me modulo infinity...
$endgroup$
Perl 6, 37 bytes
$++.polymod(1+$++ xx $_-1).say xx *
Try it online!
Essentially runs polymod with as many entries as needed, where the modulo is always greater than the input, i.e. 0.polymod( 1,1,1 ), 1.polymod( 2,2,2 ) etc. That way the digit is always within the range. Perl6 won't let me modulo infinity...
answered 2 hours ago
Phil HPhil H
1,152817
1,152817
add a comment |
add a comment |
$begingroup$
VDM-SL, 51 bytes
g(i)==if i=0thenelsex:nat,y in set g(i-1)
Recursive set comprehension with sequence concatenation..
Not on TIO, you could run in a program (if you turn on limits for nat type or it wont terminate):
functions
g:nat->set of ?
g(i)==if i=0thenelsex:nat,y in set g(i-1)
Includes the optional 0s in answer otherwise it would be 52 bytes binding on nat1
$endgroup$
add a comment |
$begingroup$
VDM-SL, 51 bytes
g(i)==if i=0thenelsex:nat,y in set g(i-1)
Recursive set comprehension with sequence concatenation..
Not on TIO, you could run in a program (if you turn on limits for nat type or it wont terminate):
functions
g:nat->set of ?
g(i)==if i=0thenelsex:nat,y in set g(i-1)
Includes the optional 0s in answer otherwise it would be 52 bytes binding on nat1
$endgroup$
add a comment |
$begingroup$
VDM-SL, 51 bytes
g(i)==if i=0thenelsex:nat,y in set g(i-1)
Recursive set comprehension with sequence concatenation..
Not on TIO, you could run in a program (if you turn on limits for nat type or it wont terminate):
functions
g:nat->set of ?
g(i)==if i=0thenelsex:nat,y in set g(i-1)
Includes the optional 0s in answer otherwise it would be 52 bytes binding on nat1
$endgroup$
VDM-SL, 51 bytes
g(i)==if i=0thenelsex:nat,y in set g(i-1)
Recursive set comprehension with sequence concatenation..
Not on TIO, you could run in a program (if you turn on limits for nat type or it wont terminate):
functions
g:nat->set of ?
g(i)==if i=0thenelsex:nat,y in set g(i-1)
Includes the optional 0s in answer otherwise it would be 52 bytes binding on nat1
answered 1 hour ago
Expired DataExpired Data
948217
948217
add a comment |
add a comment |
$begingroup$
05AB1E, 15 bytes
<[>DÅœIùvyœÙvy,
Inspired by @Lynn's Haskell answer.
Try it online.
Explanation:
< # Decrease the (implicit) input-integer by 1
[ # Start an infinite loop:
> # Increase the integer at the top of the stack by 1
D # And duplicate it (for the next iteration)
Ŝ # Create lists of national integers that sum to this integer
Iù # Only leave the lists of a size equal to the input
v # Loop over each list `y` in this list of lists:
yœÙ # Get all possible unique permutations of this list `y`
v # Inner loop over each list `y` in this list of unique permutation lists:
y, # And output this list `y` with a trailing newline
$endgroup$
1
$begingroup$
When will the program get to [1,2,1]? Remember it has to be within finite time.
$endgroup$
– billpg
3 hours ago
$begingroup$
@billpg Should be fixed now.
$endgroup$
– Kevin Cruijssen
1 hour ago
add a comment |
$begingroup$
05AB1E, 15 bytes
<[>DÅœIùvyœÙvy,
Inspired by @Lynn's Haskell answer.
Try it online.
Explanation:
< # Decrease the (implicit) input-integer by 1
[ # Start an infinite loop:
> # Increase the integer at the top of the stack by 1
D # And duplicate it (for the next iteration)
Ŝ # Create lists of national integers that sum to this integer
Iù # Only leave the lists of a size equal to the input
v # Loop over each list `y` in this list of lists:
yœÙ # Get all possible unique permutations of this list `y`
v # Inner loop over each list `y` in this list of unique permutation lists:
y, # And output this list `y` with a trailing newline
$endgroup$
1
$begingroup$
When will the program get to [1,2,1]? Remember it has to be within finite time.
$endgroup$
– billpg
3 hours ago
$begingroup$
@billpg Should be fixed now.
$endgroup$
– Kevin Cruijssen
1 hour ago
add a comment |
$begingroup$
05AB1E, 15 bytes
<[>DÅœIùvyœÙvy,
Inspired by @Lynn's Haskell answer.
Try it online.
Explanation:
< # Decrease the (implicit) input-integer by 1
[ # Start an infinite loop:
> # Increase the integer at the top of the stack by 1
D # And duplicate it (for the next iteration)
Ŝ # Create lists of national integers that sum to this integer
Iù # Only leave the lists of a size equal to the input
v # Loop over each list `y` in this list of lists:
yœÙ # Get all possible unique permutations of this list `y`
v # Inner loop over each list `y` in this list of unique permutation lists:
y, # And output this list `y` with a trailing newline
$endgroup$
05AB1E, 15 bytes
<[>DÅœIùvyœÙvy,
Inspired by @Lynn's Haskell answer.
Try it online.
Explanation:
< # Decrease the (implicit) input-integer by 1
[ # Start an infinite loop:
> # Increase the integer at the top of the stack by 1
D # And duplicate it (for the next iteration)
Ŝ # Create lists of national integers that sum to this integer
Iù # Only leave the lists of a size equal to the input
v # Loop over each list `y` in this list of lists:
yœÙ # Get all possible unique permutations of this list `y`
v # Inner loop over each list `y` in this list of unique permutation lists:
y, # And output this list `y` with a trailing newline
edited 1 hour ago
answered 3 hours ago
Kevin CruijssenKevin Cruijssen
42.8k571217
42.8k571217
1
$begingroup$
When will the program get to [1,2,1]? Remember it has to be within finite time.
$endgroup$
– billpg
3 hours ago
$begingroup$
@billpg Should be fixed now.
$endgroup$
– Kevin Cruijssen
1 hour ago
add a comment |
1
$begingroup$
When will the program get to [1,2,1]? Remember it has to be within finite time.
$endgroup$
– billpg
3 hours ago
$begingroup$
@billpg Should be fixed now.
$endgroup$
– Kevin Cruijssen
1 hour ago
1
1
$begingroup$
When will the program get to [1,2,1]? Remember it has to be within finite time.
$endgroup$
– billpg
3 hours ago
$begingroup$
When will the program get to [1,2,1]? Remember it has to be within finite time.
$endgroup$
– billpg
3 hours ago
$begingroup$
@billpg Should be fixed now.
$endgroup$
– Kevin Cruijssen
1 hour ago
$begingroup$
@billpg Should be fixed now.
$endgroup$
– Kevin Cruijssen
1 hour ago
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f183225%2flist-all-the-tuples%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
For n=6, is it acceptable to produce 0,0 .. 5,5 or does it have to include 6,6?
$endgroup$
– Phil H
3 hours ago
$begingroup$
For n=6, the 6-tuples are (1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1) etc. I'll add this to the the examples.
$endgroup$
– billpg
3 hours ago
1
$begingroup$
Each valid tuple must be listed within finite time, if only the program were allowed to run that long. .. Does this contradict the output being in any order? i.e what if my order is (1,1),(2,1),(3,1)...(n,1) and only once I've gone through every natural number will i print (1,2)
$endgroup$
– Expired Data
3 hours ago
$begingroup$
Fair point, I'll edit the rule.
$endgroup$
– billpg
3 hours ago
$begingroup$
I assume it is valid if when the program crashes it produces some extraneous output in addition to the tuples printed so far, right?
$endgroup$
– Luis Mendo
35 mins ago