New answers tagged

1 vote

Tips for golfing in Knight

Using & and | instead of IF Unless you need both the if true and if false clauses of <...
user avatar
1 vote

Tips for golfing in Knight

Use T or F instead of 1 or 0 to save a character ...
user avatar
5 votes

Python: can I shorten this code further for checking substrings

Python, 72 bytes for n in[*open(0)][1:]:print("yneos"[all(map(str.__ne__,' X '+n,n))::2]) Try it online! Knocks 5 more bytes off of Jonathan Allan's ...
user avatar
  • 9,006
3 votes

Python: can I shorten this code further for checking substrings

Python 3.8, 77 bytes input() while n:='X '+input():print("yneos"[all(map(str.__ne__,n,n[3:]))::2]) Try it online! The check for four equal characters in ...
user avatar
3 votes

Python: can I shorten this code further for checking substrings

82 bytes Can probably be golfed more, but here is a first golf: -2 bytes by changing "yes"if re.search(r"(.)\1{3}|DX",n)else"no" To: <...
user avatar
3 votes

Tips for golfing in Knight

Use coercion For example, in the case that + receives a string as the first and a number as the second arg, it will coerce the second one to a string and ...
user avatar
  • 9,006
7 votes
Accepted

Help me golf this C program checking for string patterns in a sorted hand of cards

94 bytes Instead of increasing s[1] when you find a quadruplet, setting it to zero is a bit cheaper. The conditional in puts ...
user avatar
  • 55k
2 votes

Tips for golfing in Knight

At the risk of stating the obvious, all functions can be abbreviated to a single uppercase character. For example: OUTPUT 1 O 1 You also can remove the space ...
user avatar
  • 1,423
2 votes

Tips for golfing in Knight

The ASCII function in Knight, if given a string, returns the ASCII value of just the first character of a string; if given a number, it returns the ASCII character ...
user avatar
  • 1,423
4 votes

Tips for golfing in Knight

Variables in Knight consist of a lowercase letter followed by additional lowercase letters or numbers, but not uppercase letters. This means that you don't need a space between a variable and a ...
user avatar
  • 1,423
2 votes

Tips for golfing in Knight

Since the assignment operator in Knight returns the assigned value, you can chain together definitions if, for example, you want to create multiple variables with the same value: ...
user avatar
  • 1,423
1 vote

Tips for golfing in C

Abuse wchar_t to print one character from a string In a little-endian architecture, you can replace ...
user avatar
  • 500
2 votes

Tips for golfing in Rust

Get the nth element of a String or &str slice In rust you can't directly index a string or slice. If you want to build a ...
user avatar
  • 1,635
1 vote

Tips for Code Golfing in Desmos

Regressions A regression can be used to solve an equation and can be shorter than explicitly typing out the expression for its solution. For example, the golden ratio can be calculated in 6 bytes, <...
user avatar
  • 141

Top 50 recent answers are included