Print 'A' 1000 times with BrainFuckTips for golfing in brainfuckBrainF***-optimize a series of numbersTips for golfing in brainfuckMinify BrainfuckVerify Brainfuck programBrainfuck SortingImplement multiplication by a constant with addition and bit shiftsConvert Brainfuck to another language!Find the smallest fileFind the Fibonacci KernelCover a set with multiples
Can a US president have someone sent to prison?
Fitting a mixture of two normal distributions for a data set?
Why cruise at 7000' in an A319?
Bash echo $-1 prints hb1. Why?
Why isn’t the tax system continuous rather than bracketed?
Why do some games show lights shine through walls?
Syntax Error with 'if'
Is it possible to buy a train ticket CDG airport to Paris truly online?
Does the Paladin's Aura of Protection affect only either her or ONE ally in range?
MH370 blackbox - is it still possible to retrieve data from it?
What do you call the action of someone tackling a stronger person?
What happens when your group is victim of a surprise attack but you can't be surprised?
Why is C++ initial allocation so much larger than C's?
Analog is Obtuse!
Was touching your nose a greeting in second millenium Mesopotamia?
How often can a PC check with passive perception during a combat turn?
Should I tell my insurance company I'm making payments on my new car?
In the Marvel universe, can a human have a baby with any non-human?
How to append a matrix element by element?
Calculating the partial sum of a expl3 sequence
Mount a folder with a space on Linux
Architecture of networked game engine
Inverse-quotes-quine
Use color ramp to mix materials
Print 'A' 1000 times with BrainFuck
Tips for golfing in brainfuckBrainF***-optimize a series of numbersTips for golfing in brainfuckMinify BrainfuckVerify Brainfuck programBrainfuck SortingImplement multiplication by a constant with addition and bit shiftsConvert Brainfuck to another language!Find the smallest fileFind the Fibonacci KernelCover a set with multiples
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
What is the best BrainFuck code (in terms of code size) to print 'A' 1000 times ?
My approach is:
- set 'A' to p[0]
- set 255 to p[1] to display 255 'A', 3 times
- set 235 to p[1] to display 235 'A'
This is not effective but I cannot find a way to use tow counters simultaneously like a multiplication
Is there a better approach than a multiplication ?
A more general question: is there a rule to make a multiplication with a large number with the smallest possible code?
code-golf tips brainfuck
New contributor
$endgroup$
|
show 3 more comments
$begingroup$
What is the best BrainFuck code (in terms of code size) to print 'A' 1000 times ?
My approach is:
- set 'A' to p[0]
- set 255 to p[1] to display 255 'A', 3 times
- set 235 to p[1] to display 235 'A'
This is not effective but I cannot find a way to use tow counters simultaneously like a multiplication
Is there a better approach than a multiplication ?
A more general question: is there a rule to make a multiplication with a large number with the smallest possible code?
code-golf tips brainfuck
New contributor
$endgroup$
4
$begingroup$
This is a good place to start. Welcome to Code golf! :)
$endgroup$
– FryAmTheEggman
Jun 16 at 21:02
3
$begingroup$
I think you want to just use a nested loop, but I don't know BF very well. Have you seen Brainfuck tips? Also probably the esolangs page on Brainfuck constants would be a useful resource here.
$endgroup$
– Jonathan Allan
Jun 16 at 21:02
4
$begingroup$
I think you should clarify best BrainFuck code. Are you in search of most readable, most elegant, using the least amount of+
characters or simply highest brevity?
$endgroup$
– Jonathan Frech
Jun 16 at 22:17
$begingroup$
@Jonathan Allan: Yes, that's the purpose of this question : How to use a nested loop. It's a fascinating language close ASM but I don't understand some aspects
$endgroup$
– Nelson G.
Jun 17 at 6:31
$begingroup$
Could I use this variant on BF -> github.com/gergoerdi/brainfuck64
$endgroup$
– Shaun Bebbers
Jun 17 at 10:50
|
show 3 more comments
$begingroup$
What is the best BrainFuck code (in terms of code size) to print 'A' 1000 times ?
My approach is:
- set 'A' to p[0]
- set 255 to p[1] to display 255 'A', 3 times
- set 235 to p[1] to display 235 'A'
This is not effective but I cannot find a way to use tow counters simultaneously like a multiplication
Is there a better approach than a multiplication ?
A more general question: is there a rule to make a multiplication with a large number with the smallest possible code?
code-golf tips brainfuck
New contributor
$endgroup$
What is the best BrainFuck code (in terms of code size) to print 'A' 1000 times ?
My approach is:
- set 'A' to p[0]
- set 255 to p[1] to display 255 'A', 3 times
- set 235 to p[1] to display 235 'A'
This is not effective but I cannot find a way to use tow counters simultaneously like a multiplication
Is there a better approach than a multiplication ?
A more general question: is there a rule to make a multiplication with a large number with the smallest possible code?
code-golf tips brainfuck
code-golf tips brainfuck
New contributor
New contributor
edited Jun 17 at 8:19
Nelson G.
New contributor
asked Jun 16 at 20:53
Nelson G.Nelson G.
1926 bronze badges
1926 bronze badges
New contributor
New contributor
4
$begingroup$
This is a good place to start. Welcome to Code golf! :)
$endgroup$
– FryAmTheEggman
Jun 16 at 21:02
3
$begingroup$
I think you want to just use a nested loop, but I don't know BF very well. Have you seen Brainfuck tips? Also probably the esolangs page on Brainfuck constants would be a useful resource here.
$endgroup$
– Jonathan Allan
Jun 16 at 21:02
4
$begingroup$
I think you should clarify best BrainFuck code. Are you in search of most readable, most elegant, using the least amount of+
characters or simply highest brevity?
$endgroup$
– Jonathan Frech
Jun 16 at 22:17
$begingroup$
@Jonathan Allan: Yes, that's the purpose of this question : How to use a nested loop. It's a fascinating language close ASM but I don't understand some aspects
$endgroup$
– Nelson G.
Jun 17 at 6:31
$begingroup$
Could I use this variant on BF -> github.com/gergoerdi/brainfuck64
$endgroup$
– Shaun Bebbers
Jun 17 at 10:50
|
show 3 more comments
4
$begingroup$
This is a good place to start. Welcome to Code golf! :)
$endgroup$
– FryAmTheEggman
Jun 16 at 21:02
3
$begingroup$
I think you want to just use a nested loop, but I don't know BF very well. Have you seen Brainfuck tips? Also probably the esolangs page on Brainfuck constants would be a useful resource here.
$endgroup$
– Jonathan Allan
Jun 16 at 21:02
4
$begingroup$
I think you should clarify best BrainFuck code. Are you in search of most readable, most elegant, using the least amount of+
characters or simply highest brevity?
$endgroup$
– Jonathan Frech
Jun 16 at 22:17
$begingroup$
@Jonathan Allan: Yes, that's the purpose of this question : How to use a nested loop. It's a fascinating language close ASM but I don't understand some aspects
$endgroup$
– Nelson G.
Jun 17 at 6:31
$begingroup$
Could I use this variant on BF -> github.com/gergoerdi/brainfuck64
$endgroup$
– Shaun Bebbers
Jun 17 at 10:50
4
4
$begingroup$
This is a good place to start. Welcome to Code golf! :)
$endgroup$
– FryAmTheEggman
Jun 16 at 21:02
$begingroup$
This is a good place to start. Welcome to Code golf! :)
$endgroup$
– FryAmTheEggman
Jun 16 at 21:02
3
3
$begingroup$
I think you want to just use a nested loop, but I don't know BF very well. Have you seen Brainfuck tips? Also probably the esolangs page on Brainfuck constants would be a useful resource here.
$endgroup$
– Jonathan Allan
Jun 16 at 21:02
$begingroup$
I think you want to just use a nested loop, but I don't know BF very well. Have you seen Brainfuck tips? Also probably the esolangs page on Brainfuck constants would be a useful resource here.
$endgroup$
– Jonathan Allan
Jun 16 at 21:02
4
4
$begingroup$
I think you should clarify best BrainFuck code. Are you in search of most readable, most elegant, using the least amount of
+
characters or simply highest brevity?$endgroup$
– Jonathan Frech
Jun 16 at 22:17
$begingroup$
I think you should clarify best BrainFuck code. Are you in search of most readable, most elegant, using the least amount of
+
characters or simply highest brevity?$endgroup$
– Jonathan Frech
Jun 16 at 22:17
$begingroup$
@Jonathan Allan: Yes, that's the purpose of this question : How to use a nested loop. It's a fascinating language close ASM but I don't understand some aspects
$endgroup$
– Nelson G.
Jun 17 at 6:31
$begingroup$
@Jonathan Allan: Yes, that's the purpose of this question : How to use a nested loop. It's a fascinating language close ASM but I don't understand some aspects
$endgroup$
– Nelson G.
Jun 17 at 6:31
$begingroup$
Could I use this variant on BF -> github.com/gergoerdi/brainfuck64
$endgroup$
– Shaun Bebbers
Jun 17 at 10:50
$begingroup$
Could I use this variant on BF -> github.com/gergoerdi/brainfuck64
$endgroup$
– Shaun Bebbers
Jun 17 at 10:50
|
show 3 more comments
1 Answer
1
active
oldest
votes
$begingroup$
The method you seem to currently be using is 39 bytes:
>>+++[<-[-<.>]>-]++++[<----->-]<-[-<.>]
(not including getting the A
) (Try It Online!)
(loop 3 times, each time set the counter to 255 and print that many times, then subtract 20, subtract 1, and print that many times)
However, it is much shorter to loop 250 times and print 4 times each time (thanks to jimmy23013 for optimizing this over my original loop-4 loop-250 print-1 solution):
>------[<....>-]
(16 bytes)
If your cells are unbounded (I'm assuming they're 8-bit otherwise you probably wouldn't try using 255 for golfing):
>>++++++++++[<++++++++++[<..........>-]>-]
(42 bytes).
$endgroup$
$begingroup$
this seems to assume 8-bit cells, though...
$endgroup$
– John Dvorak
Jun 16 at 21:22
2
$begingroup$
@JohnDvorak: The question mentioned setting cells to 255 as a part of the most effective solution the OP could think of. That seems like a pretty clear indication of (ab)using 8-bit cell wrapping.
$endgroup$
– randomdude999
Jun 16 at 21:25
$begingroup$
@JohnDvorak What randomdude999 said, but I did add a method using 10x10x10 in case the cells are unbounded.
$endgroup$
– HyperNeutrino
Jun 16 at 21:37
$begingroup$
250 times....
would be shorter.
$endgroup$
– jimmy23013
Jun 17 at 9:36
$begingroup$
@jimmy23013 ... not sure how I didn't think of that an still optimized my 10x10x10 solution to do that LOL. thanks!
$endgroup$
– HyperNeutrino
Jun 17 at 13:35
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
);
);
Nelson G. is a new contributor. Be nice, and check out our Code of Conduct.
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%2f186971%2fprint-a-1000-times-with-brainfuck%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
The method you seem to currently be using is 39 bytes:
>>+++[<-[-<.>]>-]++++[<----->-]<-[-<.>]
(not including getting the A
) (Try It Online!)
(loop 3 times, each time set the counter to 255 and print that many times, then subtract 20, subtract 1, and print that many times)
However, it is much shorter to loop 250 times and print 4 times each time (thanks to jimmy23013 for optimizing this over my original loop-4 loop-250 print-1 solution):
>------[<....>-]
(16 bytes)
If your cells are unbounded (I'm assuming they're 8-bit otherwise you probably wouldn't try using 255 for golfing):
>>++++++++++[<++++++++++[<..........>-]>-]
(42 bytes).
$endgroup$
$begingroup$
this seems to assume 8-bit cells, though...
$endgroup$
– John Dvorak
Jun 16 at 21:22
2
$begingroup$
@JohnDvorak: The question mentioned setting cells to 255 as a part of the most effective solution the OP could think of. That seems like a pretty clear indication of (ab)using 8-bit cell wrapping.
$endgroup$
– randomdude999
Jun 16 at 21:25
$begingroup$
@JohnDvorak What randomdude999 said, but I did add a method using 10x10x10 in case the cells are unbounded.
$endgroup$
– HyperNeutrino
Jun 16 at 21:37
$begingroup$
250 times....
would be shorter.
$endgroup$
– jimmy23013
Jun 17 at 9:36
$begingroup$
@jimmy23013 ... not sure how I didn't think of that an still optimized my 10x10x10 solution to do that LOL. thanks!
$endgroup$
– HyperNeutrino
Jun 17 at 13:35
add a comment |
$begingroup$
The method you seem to currently be using is 39 bytes:
>>+++[<-[-<.>]>-]++++[<----->-]<-[-<.>]
(not including getting the A
) (Try It Online!)
(loop 3 times, each time set the counter to 255 and print that many times, then subtract 20, subtract 1, and print that many times)
However, it is much shorter to loop 250 times and print 4 times each time (thanks to jimmy23013 for optimizing this over my original loop-4 loop-250 print-1 solution):
>------[<....>-]
(16 bytes)
If your cells are unbounded (I'm assuming they're 8-bit otherwise you probably wouldn't try using 255 for golfing):
>>++++++++++[<++++++++++[<..........>-]>-]
(42 bytes).
$endgroup$
$begingroup$
this seems to assume 8-bit cells, though...
$endgroup$
– John Dvorak
Jun 16 at 21:22
2
$begingroup$
@JohnDvorak: The question mentioned setting cells to 255 as a part of the most effective solution the OP could think of. That seems like a pretty clear indication of (ab)using 8-bit cell wrapping.
$endgroup$
– randomdude999
Jun 16 at 21:25
$begingroup$
@JohnDvorak What randomdude999 said, but I did add a method using 10x10x10 in case the cells are unbounded.
$endgroup$
– HyperNeutrino
Jun 16 at 21:37
$begingroup$
250 times....
would be shorter.
$endgroup$
– jimmy23013
Jun 17 at 9:36
$begingroup$
@jimmy23013 ... not sure how I didn't think of that an still optimized my 10x10x10 solution to do that LOL. thanks!
$endgroup$
– HyperNeutrino
Jun 17 at 13:35
add a comment |
$begingroup$
The method you seem to currently be using is 39 bytes:
>>+++[<-[-<.>]>-]++++[<----->-]<-[-<.>]
(not including getting the A
) (Try It Online!)
(loop 3 times, each time set the counter to 255 and print that many times, then subtract 20, subtract 1, and print that many times)
However, it is much shorter to loop 250 times and print 4 times each time (thanks to jimmy23013 for optimizing this over my original loop-4 loop-250 print-1 solution):
>------[<....>-]
(16 bytes)
If your cells are unbounded (I'm assuming they're 8-bit otherwise you probably wouldn't try using 255 for golfing):
>>++++++++++[<++++++++++[<..........>-]>-]
(42 bytes).
$endgroup$
The method you seem to currently be using is 39 bytes:
>>+++[<-[-<.>]>-]++++[<----->-]<-[-<.>]
(not including getting the A
) (Try It Online!)
(loop 3 times, each time set the counter to 255 and print that many times, then subtract 20, subtract 1, and print that many times)
However, it is much shorter to loop 250 times and print 4 times each time (thanks to jimmy23013 for optimizing this over my original loop-4 loop-250 print-1 solution):
>------[<....>-]
(16 bytes)
If your cells are unbounded (I'm assuming they're 8-bit otherwise you probably wouldn't try using 255 for golfing):
>>++++++++++[<++++++++++[<..........>-]>-]
(42 bytes).
edited Jun 17 at 13:35
answered Jun 16 at 21:12
HyperNeutrinoHyperNeutrino
20.3k4 gold badges41 silver badges153 bronze badges
20.3k4 gold badges41 silver badges153 bronze badges
$begingroup$
this seems to assume 8-bit cells, though...
$endgroup$
– John Dvorak
Jun 16 at 21:22
2
$begingroup$
@JohnDvorak: The question mentioned setting cells to 255 as a part of the most effective solution the OP could think of. That seems like a pretty clear indication of (ab)using 8-bit cell wrapping.
$endgroup$
– randomdude999
Jun 16 at 21:25
$begingroup$
@JohnDvorak What randomdude999 said, but I did add a method using 10x10x10 in case the cells are unbounded.
$endgroup$
– HyperNeutrino
Jun 16 at 21:37
$begingroup$
250 times....
would be shorter.
$endgroup$
– jimmy23013
Jun 17 at 9:36
$begingroup$
@jimmy23013 ... not sure how I didn't think of that an still optimized my 10x10x10 solution to do that LOL. thanks!
$endgroup$
– HyperNeutrino
Jun 17 at 13:35
add a comment |
$begingroup$
this seems to assume 8-bit cells, though...
$endgroup$
– John Dvorak
Jun 16 at 21:22
2
$begingroup$
@JohnDvorak: The question mentioned setting cells to 255 as a part of the most effective solution the OP could think of. That seems like a pretty clear indication of (ab)using 8-bit cell wrapping.
$endgroup$
– randomdude999
Jun 16 at 21:25
$begingroup$
@JohnDvorak What randomdude999 said, but I did add a method using 10x10x10 in case the cells are unbounded.
$endgroup$
– HyperNeutrino
Jun 16 at 21:37
$begingroup$
250 times....
would be shorter.
$endgroup$
– jimmy23013
Jun 17 at 9:36
$begingroup$
@jimmy23013 ... not sure how I didn't think of that an still optimized my 10x10x10 solution to do that LOL. thanks!
$endgroup$
– HyperNeutrino
Jun 17 at 13:35
$begingroup$
this seems to assume 8-bit cells, though...
$endgroup$
– John Dvorak
Jun 16 at 21:22
$begingroup$
this seems to assume 8-bit cells, though...
$endgroup$
– John Dvorak
Jun 16 at 21:22
2
2
$begingroup$
@JohnDvorak: The question mentioned setting cells to 255 as a part of the most effective solution the OP could think of. That seems like a pretty clear indication of (ab)using 8-bit cell wrapping.
$endgroup$
– randomdude999
Jun 16 at 21:25
$begingroup$
@JohnDvorak: The question mentioned setting cells to 255 as a part of the most effective solution the OP could think of. That seems like a pretty clear indication of (ab)using 8-bit cell wrapping.
$endgroup$
– randomdude999
Jun 16 at 21:25
$begingroup$
@JohnDvorak What randomdude999 said, but I did add a method using 10x10x10 in case the cells are unbounded.
$endgroup$
– HyperNeutrino
Jun 16 at 21:37
$begingroup$
@JohnDvorak What randomdude999 said, but I did add a method using 10x10x10 in case the cells are unbounded.
$endgroup$
– HyperNeutrino
Jun 16 at 21:37
$begingroup$
250 times
....
would be shorter.$endgroup$
– jimmy23013
Jun 17 at 9:36
$begingroup$
250 times
....
would be shorter.$endgroup$
– jimmy23013
Jun 17 at 9:36
$begingroup$
@jimmy23013 ... not sure how I didn't think of that an still optimized my 10x10x10 solution to do that LOL. thanks!
$endgroup$
– HyperNeutrino
Jun 17 at 13:35
$begingroup$
@jimmy23013 ... not sure how I didn't think of that an still optimized my 10x10x10 solution to do that LOL. thanks!
$endgroup$
– HyperNeutrino
Jun 17 at 13:35
add a comment |
Nelson G. is a new contributor. Be nice, and check out our Code of Conduct.
Nelson G. is a new contributor. Be nice, and check out our Code of Conduct.
Nelson G. is a new contributor. Be nice, and check out our Code of Conduct.
Nelson G. is a new contributor. Be nice, and check out our Code of Conduct.
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%2f186971%2fprint-a-1000-times-with-brainfuck%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
4
$begingroup$
This is a good place to start. Welcome to Code golf! :)
$endgroup$
– FryAmTheEggman
Jun 16 at 21:02
3
$begingroup$
I think you want to just use a nested loop, but I don't know BF very well. Have you seen Brainfuck tips? Also probably the esolangs page on Brainfuck constants would be a useful resource here.
$endgroup$
– Jonathan Allan
Jun 16 at 21:02
4
$begingroup$
I think you should clarify best BrainFuck code. Are you in search of most readable, most elegant, using the least amount of
+
characters or simply highest brevity?$endgroup$
– Jonathan Frech
Jun 16 at 22:17
$begingroup$
@Jonathan Allan: Yes, that's the purpose of this question : How to use a nested loop. It's a fascinating language close ASM but I don't understand some aspects
$endgroup$
– Nelson G.
Jun 17 at 6:31
$begingroup$
Could I use this variant on BF -> github.com/gergoerdi/brainfuck64
$endgroup$
– Shaun Bebbers
Jun 17 at 10:50