2022 Developer Survey is open! Take survey.

# Questions tagged [tips]

For questions asking for tips on golfing in a specific language, doing well in certain challenge tag, or improving a particular piece of code.

338 questions
Filter by
Sorted by
Tagged with
728 views

### Curry tips for Haskell programmers

Curry is the Language of the Month this month and some users are starting to get into it, so let's get some tips together. Haskell and Curry are similar in a lot of ways and a lot of tips for Haskell ...
• 84.9k
468 views

### Tips for golfing in Piet

Seeing that the current language for Learn You a Lang for Great Good is Piet, and that we don't seem to have a tips page for Piet yet, I decided to make one. Piet is a stack-based esoteric programming ...
• 3,890
65 views

### Tips for golfing in Fennel

Fennel is a lispy language which compiles to Lua. From its page: Fennel is a programming language that brings together the speed, simplicity, and reach of Lua with the flexibility of a lisp syntax ...
• 1,581
176 views

### Tips for golfing in Seriously

I am looking for tips to code in this golfing language Seriously, and was wondering what some of the ways for golfing this language is. "Remove comments" is not a tip. Actually is also ...
• 3,031
209 views

### How to shorten Python code involving the sum of reciprocals?

I have a coding problem that goes like this: Given a positive integer $N$, return a list of all possible pairs of positive integers $(x,y)$ such that $$\frac1x+\frac1y=\frac1N$$ I already solved ...
• 3,890
290 views

### The right way to return [[0, 0, 0], [0, 1, 0], [0, 0, 0]] [closed]

Here is the program to return [[0, 0, 0], [0, 1, 0], [0, 0, 0]] [[0]*3,[0,1,0],[0]*3] Try it online! Can you shorten this code?...
• 2,493
266 views

### Shortest way to coerce to array

Given a variable a (non array) or (any[]) convert to (any[]) function example(s: string | string[]) { const e = Array.isArray(s) ? s: [s] return e } Is ...
• 261
130 views

### Tips for golfing in Lexurgy

What general tips do you have for golfing in Lexurgy? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Lexurgy (e.g. "remove ...
• 2,813
773 views

### Can I shorten this Python code for simulating a car driving around

I am trying to write a solution to the following problem using as few characters as possible (to meme my friend and introduce him to golfing). Can any improvements be done to my code? So the problem ...
• 103
522 views

### Tips for golfing in Add++

Add++ is the Language of the Month for January 2022, and so I'm asking for tips for golfing in it. Please stick to tips specific to Add++, and avoid general tips such as "remove whitespace" ...
120 views

### Tips for golfing in VB.net [duplicate]

Any general tips for golfing in VB.net? This, similar to Pascal, is a very rarely used language, thus having very few resources online Visual Basic.NET (VB.NET) is a multi-paradigm, managed, type-safe,...
• 3,031
109 views

### Tips for golfing in Objective C

Surprisingly, I do not think this question has been asked before Although on codingame.com, Objective C and C are two of the best golfing languages there, so I would like to know some of the best ...
• 3,031
190 views

### Tips for golfing in Pascal

What general tips do you have for golfing code in Pascal? I know this is a tricky language very few people use this but I would like to know any tips from the professionals out there :) I'm looking ...
• 3,031
147 views

### In as few bytes as possible in t-sql, return 100 rows containing the phrase 'Have a great Christmas'

In as few bytes as possible in t-sql, return 100 rows containing the phrase 'Have a great Christmas' 92 (I think) to beat :D ...
536 views

### How to shorten the Python code? Part II

Code Python 3, 245 bytes ...
• 2,493
241 views

### Tips for golfing in BQN

What general tips do you have for golfing in BQN? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to BQN (e.g. "remove comments"...
• 62.1k
2k views

### How to shorten the python code?

I'm writing a program that takes a number from input (call it x), loops from 0 to (x - 1) (let's call our iterator y) and prints $y^x+x$ for each y. After the loop, it then prints "SUM: N" ...
• 2,493
466 views

### How to solve the LCM in 50 bytes of Python

I've recently stumbled upon a Russian site called acmp.ru, in which one of the tasks, HOK, asks us to find the LCM of two positive integers. The full statement, translated to English is as follows: ...
• 17k
1k views

### Tips for golfing in TypeScript's type system

What general tips do you have for golfing in TypeScript's type system? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to TypeScript's ...
• 6,740
119 views

### Tips for parsing Standard Input in JavaScript

I've been doing quite a few code golf recently and I realised that a lot of times, I have to do something involving list. Most of the times lists are space-separated or comma-separated values in the ...
• 693
253 views

### Tips for golfing in Chef

What general tips do you have for golfing in Chef? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Chef (e.g. "remove unnecessary ...
• 2,493
384 views

### Pushing the limits to make a piece of code solving the K-Goodness String problem shorter

I am trying to push my limits of making a python code as short as possible. I left the readability part way behind. I was attempting the K-Goodness String problem from Round A of Google Kick Start ...
212 views

### Shortest way to convert a float to an int [closed]

I'm not really sure if this is the right place to ask this. Now, I know I can convert a float to an int with int, but is there some shorter way?
• 3,053
397 views

### Branchless (MIPS) assembly code for median of 3

I was trying to write a short MIPS32 code for computing the median of three registers. The rules: Assume that some values are pre-loaded into \$t0, ...
• 201
398 views

### Tips for golfing in Lean

Lean is a theorem prover and programming language. It's also as of writing the Language of the Month! What tips do people have for golfing in Lean? As always, tips should be specific to to Lean (e.g....
• 84.9k
419 views

### Tuple Assignment in Pyth

I was wondering if there is any way to assign 2 values (G and H) to say a list of ["egg", "chicken"] in Pyth. In python it would be something along the lines of ...
• 743
298 views

### Tips for golfing in jq

Since jq is the Language Of The Month for September 2021, what general tips do you have for golfing in jq? I'm looking for ideas which can be applied to code-golf problems and which are also at least ...
• 27.3k
166 views

### Tips for Golfing the Lambda Calculus & Friends

This includes tips for all related derivatives, as coding in these langs often primarily consists of writing the function in the lambda calculus and then compiling it down at the end. Among others, ...
• 1,921
998 views

### How to golf a fork in Haskell?

I'm trying to make a pointfree function f that can act like APL's dyadic forks/Husk's §, so ...
• 9,266
2k views

### How to ignore first user input in Python 3

I have 2 inputs: 1 single number and some numbers separated by whitespace: 1 1 2 3 4 5 I want to loop over the second input, and I don't need the first input. I ...
• 533
212 views

### Tips for Golfing in ARM

Because ARM is the July 2021 LoTM, I figured I'd create the tips thread. ARM is probably the most successful architecture for the digital world. From mobile phones to supercomputers, ARM is everywhere!...
• 21k
194 views

### Tips on golfing this Python program to generate a palindrome from a string

I wrote this function in 48 bytes and I wonder, is there any way to write this code 2 characters shorter? p=lambda n,c:(n*c)[:n//2]+(n*c)[:n//2+n%2][::-1] The ...
2k views

### Tips for Code Golfing in Desmos

Desmos is mainly used as an online graphing calculator, but its graphical and mathematical functionalities can also be applied in certain coding challenges. I know not that many people use Desmos on ...
• 3,890
275 views

### Tips for golfing in Z80 or SM83 machine code

There's only one question for machine-language golfing, and it's for the ia32 and amd64 architectures. Here's one for a predecessor of them: the Zilog Z80! The ISA is available here. As usual, if your ...
• 1,243
286 views

### Tips for golfing in Red

As the June 2021 Language of the Month is Red, what are some general tips for golfing in Red language? Please suggest tips that are at least somewhat specific to Red (e.g. "remove comments" ...
• 11.9k
153 views

### Tips for code golfing in Vlang

What tips do you have for code-golfing in the V lang? I have been trying to find ways to shorten codegolfs on there but can't find any resources on it. Do you guys have any? Please suggest tips that ...
• 41
306 views

### Tips for golfing a fibonacci sequence generator

One day in July 2020, I made the following C program: ...
• 11.3k
1 vote
68 views

### System-defined short forms for function-option combinations in Mathematica? [closed]

Several Mathematica functions have system-defined short forms, e.g., /@ for Map. Many of them are listed here: https://reference.wolfram.com/language/tutorial/OperatorInputForms.html However, there ...
• 1,437
596 views

### Programming Less-Than, Greater-Than and Equal-To functions using Restricted Source [closed]

I'm currently working with a branchless language which does not have native Less-Than, Greater-Than or Equal-To functions. I do however have min, ...
• 7,464
3k views

### How can this code be more "golfed"?

I'm not sure if this is the right place to ask, but I found this similar question so I'll go ahead. I'm very new to code golfing, so keep your smothered laughs and throw-up emoji's to yourselves ...
229 views

### Tips for golfing in Binary Lambda Calculus

BLC (Binary Lambda Calculus) is a binary encoding of untyped lambda calculus which was created to “provide a very simple and elegant concrete definition of descriptional complexity.” What are some ...
• 345
759 views

### Tips for Golfing in Vyxal

Vyxal is a golfing language that has 500+ different commands (achieved through overloads), and is a known beater of Jelly, 05AB1E and most golfing languages. Henceforth, it seems like a good idea to ...
• 21k
1k views

### Display 0 - 1000 - 0 each on a separate line

I've tried this question on two forums and have been told this is the best place for this type of question. I'm trying to print from 0 to 1000 then back to 0 again (and all numbers in-between), ...
• 171
246 views

### Tips for restricted source in Powershell

Adapted from Tips for restricted source in Python Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the Powershell language. Now, We already have a place to ...
• 11.9k
281 views

### Tips for restricted source in zsh

Adapted from tips for restricted-source in Python Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the zsh language. While we already have a place to collect ...
• 18.4k
256 views

### Maximum distance to station

Looking at the following hackerrank problem: https://www.hackerrank.com/challenges/flatland-space-stations You are given a number n where cities can be at indices 0 to n-1 and also given an unsorted ...
247 views

### Tips for golfing in Whispers

Whispers is February 2021's Language of the Month, so what tips do you have for golfing in it? Tips do not have to be specific to code-golf, so long as they apply to other types of challenges on the ...
264 views

### Generating versions of an array with elements changed in ruby

I'm new to code golf challenges. My problem came up in Advent of Code 2020 Day 8 The input is an array of arrays. In part two of the problem one needs to run several trials to produce a result by ...
723 views

### How to golf evaluation of math expression in MySQL?

The challenge given to me is comparatively easy, and specific to MySQL only. I'm given a table expressions which have mathematical calculations done by a kid. ...
• 2,850
1 vote