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
2
votes
2answers
87 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 ...
4
votes
0answers
122 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 ...
5
votes
2answers
323 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 ...
-1
votes
1answer
170 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?
10
votes
2answers
299 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, ...
6
votes
3answers
369 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....
5
votes
1answer
409 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 ...
8
votes
7answers
253 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 ...
2
votes
0answers
142 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, ...
14
votes
1answer
951 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 ...
6
votes
2answers
947 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 ...
8
votes
3answers
189 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!...
5
votes
1answer
172 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 ...
18
votes
9answers
1k 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 ...
6
votes
8answers
216 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 ...
8
votes
9answers
261 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" ...
3
votes
2answers
142 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 ...
11
votes
1answer
283 views

Tips for golfing a fibonacci sequence generator

One day in July 2020, I made the following C program: ...
1
vote
0answers
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 ...
2
votes
3answers
537 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, ...
21
votes
9answers
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 ...
7
votes
1answer
197 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 ...
12
votes
11answers
549 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 ...
15
votes
3answers
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), ...
5
votes
3answers
231 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 ...
10
votes
5answers
255 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 ...
2
votes
6answers
252 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 ...
5
votes
2answers
237 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 ...
7
votes
1answer
252 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 ...
12
votes
3answers
696 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. ...
1
vote
0answers
136 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! ...
7
votes
1answer
337 views

How to golf wrap-around assignments?

This is a relatively simple question. I'm trying to golf a Snake game I've written, and I'm trying to work out if there's a way to golf the following conditional assignments which control x and y ...
14
votes
2answers
661 views

Tips for restricted source in Haskell

I tested the waters on this sort of question with python, but now I get to the real question I want to ask. restricted-source challenges are uniquely rewarding in Haskell because of Haskell's strict ...
5
votes
7answers
345 views

Tips for golfing in Scala 3

What general tips do you have for golfing in Scala 3? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Scala 3 (e.g. "remove ...
14
votes
8answers
869 views

Tips for golfing in Pip

Pip is an imperative golfing language with infix operators. It also borrows some features from functional and array programming. What general tips do you have for golfing in Pip? I'm looking for ...
3
votes
2answers
382 views

Remove duplicates from list and order it by count? (python 3)

How do I remove all duplicates from list and order it based on count? ...
40
votes
17answers
5k views

Tips for restricted source in Python

Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the Python language. We already have a place to collect all these tips for code-golf, those for restricted-...
3
votes
1answer
390 views

Redirect HTTP links to HTTPS with Javascript

What is the shortest way to secure a site with Javascript? I am new to Code Golfing, and this is what I've come up with so far. I bet that this could be improved though: Challenge: Make a script ...
4
votes
1answer
162 views

Which languages are optimal for problems that require "reading" input while also writing to it like a stack

When encountering a problem whose input is meant to be read sequentially, but you may also want to push back onto the input like a stack, which languages have the optimal boilerplates for doing so, ...
1
vote
2answers
675 views

Shortest Python 3 for sum of arithmetic progression

Input: from STDIN number of vertices in Graph \$2 \leq N \leq 100\$. Rules: [Code size] = max ([code length without spaces, tabs and newlines], [total code length divided by 4]) Math formulation: In ...
4
votes
2answers
1k views

Shortest python3 code for: Find the difference between a number and a power of two not exceeding a given number

So, this is a task from one very popular educational site in Russia: https://acmp.ru/index.asp?main=task&id_task=786&ins=1 Mathematically, you need to find the power of two not exceeding the ...
0
votes
6answers
594 views

LeetCode 552: Student Attendance Record II

I'm posting my code for a LeetCode problem copied here. If you have time and would like to golf for a short solution, please do so. Requirement It has to only pass the LeetCode's Online Judge, if the ...
2
votes
2answers
271 views

Is there a language that supports Turing machines? [closed]

Is there a programming language that supports single tape Turing machines specified in some format? I am aware multiple formats for expressing them exist, but is there a standard one using which an ...
6
votes
1answer
2k views

Resource for generating shortest regex given a list of strings

I'm looking for a program such that, given a finite list of strings, can find short regexes to match exactly all of them and nothing else. Since there are multiple languages that express regexes ...
0
votes
1answer
230 views

List of programming languages that can run code at runtime [closed]

What all languages have a construct similar to python's eval, so you can write code during runtime and run it? A list would be helpful for certain programming ...
9
votes
1answer
290 views

Multiplication algorithm on a 4004

So I was playing around with this emulator of the Intel 4004 and decided I wanted to set a challenge for myself. The first use for the 4004 was in a calculator, so I decided that I would try to code ...
2
votes
1answer
122 views

Code golfing my guess the number game with feedback in NS-HUBASIC - Can it be code golfed any further?

The player has to keep guessing a number from 1 to 10 until they guess the correct number to win the game. If they make an incorrect guess, they're told if their guess was too low or too high. Each ...
2
votes
1answer
168 views

Tips for Golfing in Symja

Symja is a "computer algebra language & Java symbolic math library for Android NCalc calculator". It's a fun little language, so I'm wondering if y'all have any tips for golfing in Symja. As per ...
4
votes
2answers
121 views

Tips for golfing in Pure Data

Pure data is a graphical programming language designed for audio processing. This makes it unsuitable for most general programming but especially unsuitable for code-golf. It would then be nice to ...
4
votes
1answer
255 views

Best free online resources to learn competitive programming [closed]

I am quite proficient in C++ and Java and want to learn competitive programming to participate in contests like Google codejam and other online contests held on sites like CodeChef and Codeforces. I ...

1
2 3 4 5
7