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.

Filter by
Sorted by
Tagged with
10 votes
1 answer
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 ...
user avatar
  • 84.9k
10 votes
2 answers
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 ...
user avatar
  • 3,890
2 votes
0 answers
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 ...
user avatar
  • 1,581
3 votes
0 answers
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 ...
user avatar
  • 3,031
7 votes
2 answers
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 ...
user avatar
  • 3,890
-8 votes
1 answer
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?...
user avatar
  • 2,493
12 votes
2 answers
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 ...
user avatar
7 votes
6 answers
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 ...
user avatar
  • 2,813
10 votes
2 answers
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 ...
user avatar
12 votes
4 answers
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" ...
user avatar
2 votes
2 answers
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,...
user avatar
  • 3,031
4 votes
0 answers
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 ...
user avatar
  • 3,031
5 votes
3 answers
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 ...
user avatar
  • 3,031
7 votes
2 answers
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 ...
user avatar
4 votes
3 answers
536 views

How to shorten the Python code? Part II

Code Python 3, 245 bytes ...
user avatar
  • 2,493
11 votes
3 answers
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"...
user avatar
  • 62.1k
9 votes
4 answers
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" ...
user avatar
  • 2,493
20 votes
1 answer
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: ...
user avatar
8 votes
9 answers
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 ...
user avatar
  • 6,740
2 votes
2 answers
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 ...
user avatar
9 votes
0 answers
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 ...
user avatar
  • 2,493
6 votes
2 answers
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 ...
user avatar
-1 votes
1 answer
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?
user avatar
  • 3,053
10 votes
2 answers
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, ...
user avatar
  • 201
9 votes
3 answers
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....
user avatar
  • 84.9k
5 votes
1 answer
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 ...
user avatar
  • 743
10 votes
7 answers
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 ...
user avatar
  • 27.3k
4 votes
0 answers
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, ...
user avatar
  • 1,921
16 votes
1 answer
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 ...
user avatar
  • 9,266
7 votes
2 answers
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 ...
user avatar
  • 533
10 votes
3 answers
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!...
user avatar
  • 21k
5 votes
1 answer
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 ...
user avatar
21 votes
14 answers
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 ...
user avatar
  • 3,890
8 votes
8 answers
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 ...
user avatar
9 votes
9 answers
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" ...
user avatar
  • 11.9k
4 votes
2 answers
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 ...
user avatar
  • 41
11 votes
1 answer
306 views

Tips for golfing a fibonacci sequence generator

One day in July 2020, I made the following C program: ...
user avatar
1 vote
0 answers
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 ...
user avatar
  • 1,437
3 votes
3 answers
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, ...
user avatar
22 votes
9 answers
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 ...
user avatar
8 votes
1 answer
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 ...
user avatar
  • 345
16 votes
15 answers
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 ...
user avatar
  • 21k
16 votes
3 answers
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), ...
user avatar
  • 171
6 votes
3 answers
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 ...
user avatar
  • 11.9k
12 votes
5 answers
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 ...
user avatar
  • 18.4k
2 votes
6 answers
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 ...
user avatar
6 votes
2 answers
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 ...
user avatar
7 votes
1 answer
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 ...
user avatar
12 votes
3 answers
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. ...
user avatar
  • 2,850
1 vote
0 answers
146 views

Printing Hello World using fewest characters [duplicate]

I saw a problem which asks you to print "Hello World" using the fewest characters, including spaces. How can I further shorten this code? Thank you in advance! ...
user avatar
  • 11

1
2 3 4 5
7