Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Activity for General Sebast1an‭

Type On... Excerpt Status Date
Answer A: Reverse an ASCII string
[Java (JDK)], 88 83 bytes static void f(String s){for(int i=s.length();i>0;System.out.print(s.charAt(--i)));} Try it online!
(more)
over 2 years ago
Answer A: Make $2 + 2 = 5$
[Java (JDK)], 51 50 23 21 bytes x->y->x==y&y==2?5:x+y Try it online! Golfed 27 bytes thanks to @Moshi's advice. Golfed 2 bytes thanks to @user's advice on Discord.
(more)
over 2 years ago
Answer A: Tips for golfing in Java
A clever way to replace `Math` functions You can shorten `if-else` statements through the `a?b:c` syntax, where `a` is the statement of `if`, `b` is the result of `if`, and `c` is the result of `else`. static void main(String[]a){ &#9;int i = 95; &#9;System.out.print(i&gt;0?"positive":"ne...
(more)
over 2 years ago
Answer A: Tips for golfing in Java
Booleans are replaceable Java, like Python, has pretty convenient yet nasty ways to golfing down code through comparison operators. Especially this case, this time with booleans. You can compare `int`s and it will result to either `false` or `true`, which helps you break 1 and 2 bytes respectively...
(more)
over 2 years ago
Answer A: Collatz conjecture; Count the tries to reach $1$
[Java (JDK)], 150 bytes interface M{static void main(String[]a){int i=new java.util.Scanner(System.in).nextInt(),j=0;for(;i!=1;j++){i=i%2==1?i3+1:i/2;}System.out.print(j);}} Try it online! From my shortC answer.
(more)
over 2 years ago
Answer A: 99 Shortened Bottles of Beer
[Java (JDK)], 311 301 296 bytes interface A{static void main(String[]x){String a=" bottle",b=" of beer",c=" on the wall. ",e;for(int i=99;i>0;i--){e=i>1?"s":"";System.out.println(i+a+e+b+c+(i)+a+e+b+(i>1?".\nTake one down and pass it around. ":".\nGo to the store and buy some more. ")+(i>1...
(more)
over 2 years ago
Answer A: Tips for golfing in Java
Use `interface` The special thing about this is that it lets you drop `public` when you originally call a `class` to run the `main` function. ```java class F{public static void main(String[]a{}} interface M{static void main(String[]a){}} ``` Try it online! Used on "Hello, {name}!"
(more)
over 2 years ago
Answer A: Tips for golfing in Java
Use `for(;;)` instead of `while(true)` The title's self-explanatory. A byte saver.
(more)
over 2 years ago
Question Tips for golfing in Java
This is a list of golfing tips for the language known as Java. If you have a tip, add it in!
(more)
over 2 years ago
Question Operation "Find The Operator"
Challenge Make a program that takes input of 3 non-negative integers: a result and 2 other values that once calculated results to the 3rd value. - The program must figure out how to get the 2 first numbers to equivalence itself with the 3rd. It could be either addition, subtraction, multiplicat...
(more)
over 2 years ago
Answer A: "Hello, World!"
[Seriously], 1 byte H Try it online! Similar to HQ9+.
(more)
over 2 years ago
Answer A: 99 Shortened Bottles of Beer
[Seriously], 1 byte N Try it online! Yep. lmao
(more)
over 2 years ago
Answer A: Truthify an array
[shortC], 78 bytes i,j;f(Ix,Iy,Ip){R"[");O;i<x;i++)Oj=0;j<y;j++)p++&&R"[%d,%d],",i,j);J"\b]");} Try it online! From @Lundin's C (gcc) answer.
(more)
over 2 years ago
Answer A: "Hello, {name}!"
[shortC], 30 bytes B){Cs[100];Qs);R"Hello, %s!",s Try it online!
(more)
over 2 years ago
Answer A: Obligatory Quine Challenge
[shortC], 38 bytes Bs){Rs="Bs){Rs=%c%s%c,34,s,34",34,s,34 Try it online! From GeeksForGeeks's C implementation.
(more)
over 2 years ago
Answer A: Collatz conjecture; Count the tries to reach $1$
[shortC], 47 bytes a,b;AOK"%d",&b);b-1;b=b%2?b3+1:b/2)a++;R"%d",a Try it online! From @ugoren's C answer from CGCC.
(more)
over 2 years ago
Answer A: 99 Shortened Bottles of Beer
[shortC], 223 bytes AOCw=" bottles of beer on the wall",i=100;--i;)R"%d%.s%s, %d%.s%.8s.\n%s, %d%.s%s.\n\n",i,i-1?8:7,w,w+8,i,i-1?8:7,w,w+8,i^1?"Take one down and pass it around":"Go to the store and buy some more",i^1?i-1:99,i^2?8:7,w,w+8 Try it online! From @Lundin's C (gcc) answer. ...
(more)
over 2 years ago
Answer A: Repeat the characters
[shortC], 40 37 bytes i;f(Cs,In){O;s;s++)Oi=n;i--;Ps));} Try it online! A shortC conversion of @Lundin's C (gcc) implementation.
(more)
over 2 years ago
Answer A: Reverse an ASCII string
[shortC], 24 bytes f(Cs){s&&f(s+1)^Ps);} Try it online! A shortC conversion of @Sisyphus's C (gcc) implementation.
(more)
over 2 years ago
Answer A: Encode and decode floating point integers
[Python 3], 268 250 235 233 210 197 148 bytes def a(n):e=(n>>6).bitlength();f=2e;l=n&(f-1);N=(n>>e)&31;return((e+(n>31))f) def b(r):E=r>>5;return((r&31)+32(E>0))2(E-(E>0)) Try it online! Golfed 15 bytes thanks to @celtschk's advice. Golfed another 23 bytes thanks to @celtschk's ...
(more)
over 2 years ago
Article Operation "Find The Operator" [released]
Challenge Make a program that takes input of 3 non-negative integers: a result and 2 other values that once calculated results to the 3rd value. - The program must figure out how to get the 2 first numbers to equivalence itself with the 3rd. It could be either addition, subtraction, multiplicat...
(more)
over 2 years ago
Answer A: Tips for golfing in Python
`| == or` This bitwise operator can sometimes be used as the replacement for `or`. a=-2;b=3 if(a>0)|(b>0):print(a+b) Try it online!
(more)
over 2 years ago
Answer A: 1, 2, Fizz, 4, Buzz!
[shortC], 95 93 91 bytes AIi;Wi++<100){Ch[]={"%d "," "},p=h;i%3||(p++="Fizz%2$s");i%5||(p="Buzz ");Rh,i,h[1]); Try it online! From @celtschk's C (gcc) answer.
(more)
over 2 years ago
Answer A: Convert integer to English
[Python 3], 596 589 585 482 468 467 429 bytes def f(x): &#9;s="";i="r fif six seven eigh nine";a=f"zero one two three four five six seven eight nine ten eleven twelve thir fou{i} twen thir fo{i}".split();t=1000;c=tt &#9;if x&gt;=c:s=f(x//c)+" million";x%=c &#9;if x&gt;=t:s+=" "(s&gt;"")+f(x...
(more)
over 2 years ago
Article 99 FizzBuzzes of Beer On Golf [cancelled]
Background Randomly encountered this challenge on CGCC. Looks like a nice challenge, and since the 2 originating challenges are already here, why not add this to the fun? Challenge Recreate the "99 Bottles of Beer" song, however, "beer" is twisted by the FizzBuzz sequence, where if the value...
(more)
over 2 years ago
Answer A: "Hello, World!"
[shortC], 16 bytes AJ"Hello, World! Try it online!
(more)
over 2 years ago
Answer A: The Ludic Numbers
[Python 3], 80 77 75 72 bytes def f(): &#9;yield 1;l=[range(2,236425)] &#9;while l:yield l[0];del l[::l[0]] Try it online! Prints out the whole sequence. I did my best to get the biggest number that won't crash the program. Golfed 3 bytes thanks to @Moshi's advice.
(more)
over 2 years ago
Question Reverse your quine
Challenge Write a program that prints its reversed self. For example, if your code is ``` foo() ``` Then it'll output: ``` )(oof ``` Make sure that the quine is a valid one, as defined here: > No cheating -- that means that you can't just read the source file and print it. Also, in ...
(more)
over 2 years ago
Article Reverse your quine [released]
Challenge Write a program that prints its reversed self. For example, if your code is ``` foo() ``` Then it'll output: ``` )(oof ``` Make sure that the quine is a valid one, as defined here: > No cheating -- that means that you can't just read the source file and print it. Also, in ...
(more)
over 2 years ago
Question Collatz conjecture; Count the tries to reach $1$
Background Check out this video on the Collatz conjecture, also known as A006577. If you don't know what this is, we're given an equation of $3x + 1$, and it is applied this way: - If $x$ is odd, then $3x + 1$. - If $x$ is even, then $\frac{x}{2}$. This will send us in a loop of `4 → 2 →...
(more)
over 2 years ago
Answer A: Tips in golfing using PHP
Set arrays without `array()` In a few occasions, setting an array using `array()` can be a bit costly. Thankfully, you can assign an array like how to assign a Python list. <?php $a=["Hello","MarkFuncs","Golfing"];printr($a); Try it online!
(more)
over 2 years ago
Answer A: Tips in golfing using PHP
Whitespace can be removed in between keywords and variables You can easily remove the whitespace that's in-between a keyword (`return` or a function that doesn't need parentheses) and a variable (either starting with `$` for the variable's name or `"` if the variable to deal with is a string): ...
(more)
over 2 years ago
Answer A: Tips in golfing using PHP
Anything that's outside the script is echoed This probably has to deal with the fact that PHP is a script commonly used on HTML, and anything that is written on the HTML document--not inside the script--is outputted. Used on "Hello, World!".
(more)
over 2 years ago
Answer A: Tips in golfing using PHP
Use `Used on Reverse an ASCII string.
(more)
over 2 years ago
Answer A: Tips in golfing using PHP
Remove `?>` You can save 2 bytes by removing the syntax that ends the PHP script when you don't need it. The program will still work. <?php echo"Hello!"; Try it online!
(more)
over 2 years ago
Question Tips in golfing using PHP
This is a list of golfing tips for the language known as Philippine Peso PHP. If you have a tip, add it in!
(more)
over 2 years ago
Answer A: Tips for golfing in Python
Use `a+=[b]` instead of `a.append(b)` The title says it all. a=[];b=10;print(a) a+=[b];print(a) Try it online!
(more)
over 2 years ago
Answer A: Tips for golfing in Python
` == and` If you want to check if two booleans or integers and want to check if both of them are `true` in an `if` statement, then you can leave out `and` to replace it with ``: x=2;y=3 if x and y:print("Yes") if xy:print("Yes") Try it online!
(more)
over 2 years ago
Answer A: Tips for golfing in Python
Combine loops Suppose you have a `for` loop in another, maybe a couple of times, and nothing else inside of the outer `for` loops (except for the first `for` loop since anything outside won't be involved at all). It's probably a `range()` problem again. If you're doing something like this: ...
(more)
over 2 years ago
Answer A: It's Hip to be Square
[PHP], 69 37 bytes <?=($y=sqrt($x=fgets(STDIN)))$y==$x; Try it online! Golfed 32 bytes thanks to @Shaggy's advice.
(more)
over 2 years ago
Question Abbreviate everything
Challenge Make a program that takes input of a string and abbreviate it. - All letters of an abbreviation are capitalized, so keep that in mind. - Whitespace, numbers and non-English characters are ignored. - If the inputted string is a paragraph (2+ sentences), the abbreviation will be split...
(more)
over 2 years ago
Answer A: Getting perfect squares, differently
[PHP], 57 bytes <?php $x=0;$y=1;while(1){echo(string)($x+=$y)." ";$y+=2;} Try it online! PHP's a nice language, I tell ya.
(more)
over 2 years ago
Answer A: A number adder, not a death adder
[PHP], 58 28 bytes P1: <?=$argv[1]+10; Try it online!
(more)
over 2 years ago
Answer A: Evens or Odds - you know this one
[PHP], 36 bytes <?php $x=(int)fgets(STDIN);echo$x%2; Try it online! Outputs `1` if odd and `0` if even.
(more)
over 2 years ago
Answer A: Reverse an ASCII string
[PHP], 32 24 bytes <?=strrev(fgets(STDIN)); Try it online!
(more)
over 2 years ago
Answer A: 1, 2, Fizz, 4, Buzz!
[PHP], 114 bytes Philippine Peso this language, it was tricky.
(more)
over 2 years ago
Answer A: Tips for golfing in Python
Replace `range()` if $n for i in 0,1,2,3:print(i) Try it online!
(more)
over 2 years ago
Answer A: Repeat the characters
[Python 3], 53 38 bytes def f(x,y): &#9;for c in x:print(end=cy) Try it online! I'm sure someone will find a `lambda` solution to this. Golfed 15 bytes thanks to @Moshi's advice.
(more)
over 2 years ago
Answer A: "Hello, {name}!"
[PHP], 55 27 21 bytes Hello, ! Try it online! Golfed 28 bytes thanks to my Software CD post. Golfed 6 bytes thanks to @Shaggy's advice.
(more)
over 2 years ago
Question Define a mathematical expression in English
Background Inspired by this challenge that is also a mathematical English translator. Challenge Write a program that translates a mathematical expression using English with the following specifications: - The expression can only take in numbers, letters from the English alphabet, the equa...
(more)
over 2 years ago