Posts by General Sebast1an
Python 3, 80 77 75 72 bytes def f(): yield 1;l=[*range(2,236425)] 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 t...
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 cheatin...
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...
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","Ma...
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 (ei...
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 s...
Use <?= It's basically the same as <?php echo. Used on Reverse an ASCII string.
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!
This is a list of golfing tips for the language known as Philippine Peso PHP. If you have a tip, add it in!
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!
* == 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:pri...
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 involve...
PHP, 69 37 bytes <?=($y=sqrt($x=fgets(STDIN)))*$y==$x; Try it online! Golfed 32 bytes thanks to @Shaggy's advice.
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 ar...
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.
PHP, 58 28 bytes P1: <?="<?=\$argv[1]+$argv[1];"; Try it online! Golfed 30 bytes thanks to @Shaggy's advice. P2 (given I inputted 10): <?=$argv[1]+10; Try it online!
PHP, 36 bytes <?php $x=(int)fgets(STDIN);echo$x%2; Try it online! Outputs 1 if odd and 0 if even.
PHP, 114 bytes <?php for($i=1;$i<101;$i++){if($i%3!=0&$i%5!=0){echo$i;}if($i%3==0){echo"Fizz";}if($i%5==0){echo"Buzz";}echo"\n";} Try it online! As someone who doesn't code much in...
Replace range() if $n < 4$ If you're using a for loop, you're probably using range() for the list count. You can actually replace it if the number inside range() is less than 4. Why? Examine th...
Python 3, 53 38 bytes def f(x,y): for c in x:print(end=c*y) Try it online! I'm sure someone will find a lambda solution to this. Golfed 15 bytes thanks to @Moshi's advice.
PHP, 55 27 21 bytes Hello, <?=$argv[1]?>! Try it online! Golfed 28 bytes thanks to my Software CD post. Golfed 6 bytes thanks to @Shaggy's advice.
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 specifi...