A Code-Golf challenge

A forum where anything goes. Introduce yourselves to other members of the forums, discuss how your name evolves when written out in the Game of Life, or just tell us how you found it. This is the forum for "non-academic" content.
Post Reply
Hunting
Posts: 4395
Joined: September 11th, 2017, 2:54 am

A Code-Golf challenge

Post by Hunting » July 18th, 2019, 9:04 am

Input: Inputn Integer N
Output: Prints the character *(ASCII42) N times
Here are my current candidates:

Code: Select all

Python 2, 16 characters
print"*"*input()
Charcoal, 3 characters
×*N
or
FN*
Befunge, 18 characters
&>"*",v
 |:-1<<
 @
GolfScript, 5 characters
~"*"*
Mathematica, 19 characters by AlephAlpha
StringRepeat["*",n]
05AB1E, 6 characters
I"*"2Λ
Pyth, 4 characters
*Q"*
brainfuck, 25 characters by toroidalet
+++++++[->++++++<],[<.>-]
Last edited by Hunting on January 20th, 2020, 12:58 pm, edited 3 times in total.

User avatar
testitemqlstudop
Posts: 1367
Joined: July 21st, 2016, 11:45 am
Location: in catagolue
Contact:

Re: A Code-Golf challenge

Post by testitemqlstudop » July 18th, 2019, 9:17 am

Brainfuck + number input (not ASCII input)

Code: Select all

++++++++++++++++++++++++++++++++++++++++++>,[<.>-]
C++ (lousy golfing, yeh yeh)

Code: Select all

#include <iostream>
int main(){int i;std::cin>>i;for(;i;i--,std::cout<<'*');}

Hunting
Posts: 4395
Joined: September 11th, 2017, 2:54 am

Re: A Code-Golf challenge

Post by Hunting » July 18th, 2019, 10:11 am

testitemqlstudop wrote:Brainfuck + number input (not ASCII input)

Code: Select all

++++++++++++++++++++++++++++++++++++++++++>,[<.>-]
C++ (lousy golfing, yeh yeh)

Code: Select all

#include <iostream>
int main(){int i;std::cin>>i;for(;i;i--,std::cout<<'*');}
Brainfuck: Neat.
C++: Easily reduced

Code: Select all

#include <iostream>
main(){int i;std::cin>>i;for(;i;i--,putchar('*'));}
Last edited by Hunting on November 7th, 2019, 12:02 am, edited 1 time in total.

Naszvadi
Posts: 1248
Joined: May 7th, 2016, 8:53 am
Contact:

Re: A Code-Golf challenge

Post by Naszvadi » July 18th, 2019, 11:07 am

My 2cents:
Enjoy it!

And for the post opener, an "Alert! Spoilers!" remark would be nice!

User avatar
Moosey
Posts: 4306
Joined: January 27th, 2019, 5:54 pm
Location: here
Contact:

Code-Golf challenges

Post by Moosey » November 6th, 2019, 6:11 pm

X-post bf tetrational growth w/respect to input:
,[>>++[[[>]+[<]>-]>[>]<<[->[-<++>]<<]]>[<+>-]<<<-]
To iterate, simply add [>>++ after the , and >>[<<+>>-]<<<<-] after everything:
Pentational:
,[>>++[>>++[[[>]+[<]>-]>[>]<<[->[-<++>]<<]]>[<+>-]<<<-]>>[<<+>>-]<<<<-]

Note: the RLEs here are probably more right than what I have here, point out any errors in what I have here.

Challenge: write a BF knuth-arrow evaluator
not active here but active on discord

User avatar
toroidalet
Posts: 1514
Joined: August 7th, 2016, 1:48 pm
Location: My computer
Contact:

Re: A Code-Golf challenge

Post by toroidalet » November 24th, 2019, 2:47 pm

Shorter solution in b****fuck for the original challenge:

Code: Select all

+++++++[->++++++<],[<.>-] or
++++++[->+++++++<],[<.>-]
Any sufficiently advanced software is indistinguishable from malice.

Post Reply