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
4
votes
2answers
255 views

Tips for golfing in Sesos

If you have any tips regarding golfing in Sesos, a language made by Dennis, and nobody else has covered them yet, please post them here! Only one tip is allowed per answer. Your tip should be at least ...
11
votes
2answers
4k views

Creating a function over multiple lines

I'm attempting to create a function over multiple lines. Parameters of the challenge: Function returns 'barbarian' Only 2 characters per line 40 lines maximum. I keep trying to use a fat arrow to ...
13
votes
4answers
539 views

Tips for golfing with numpy, scipy, or pylab

There's already a comprehensive list of tips for python here, so what I'm asking for are tips that specifically apply to using the numpy, ...
2
votes
3answers
363 views

Tips for golfing in Visual Basic .NET

This page is not for Visual Basic Tips Visual Basic .NET (VB.NET) is an multi-paradigm dialect of basic that was developed and released by Microsoft in 2002 as a replacement for Visual Basic. The ...
2
votes
2answers
268 views

Tips for golfing in Visual Basic

This page is not for Visual Basic .NET Tips or VBA tips Visual Basic (VB or VB6) is an object-oriented and event-driven dialect of basic that was developed and released by Microsoft in 1991. The last ...
2
votes
6answers
343 views

Tips for golfing Yabasic

Yabasic, or Yet Another Basic is a dialect of basic created by Marc-Oliver Ihm that may be run on Windows, Unix and PAL versions of the Sony PlayStation 2. Development for this language is ongoing. ...
4
votes
1answer
422 views

Help golfing this solution further

We are doing a PCG challenge at work, and I'm submitting answers in C#. This is a modification of the "M'Kay" challenge. My solution has been deemed correct by the requirements, I'm just trying to ...
18
votes
9answers
2k views

Tips for golfing in Clean

What general tips do you have for golfing in Clean? Please post only ideas that can be applied to code golf problems in general, and are at least somewhat specific to Clean. If you've never heard of ...
2
votes
4answers
146 views

Tips for golfing in uBasic

UBASIC is a freeware basic interpreter written by Yuji Kida at Rikkyo University in Japan, specialized for mathematical computing. It is considered to be a "ready-to-run" language that and ...
13
votes
2answers
680 views

How to solve the total task on "return true to win" in 21 chars

There is a site called "Return True to Win" with interesting tasks for Javascript programmers. The goal is to find arguments to a given function that force it to return true. The following is one of ...
-3
votes
1answer
1k views

Number of leap years between two given years (inclusive) [closed]

Is there a better way to calculate the number of leap years between two given years? I want to make my code shorter (in Python). Do you have any suggestions? Here is my solution: ...
17
votes
7answers
817 views

Tips for golfing in Husk

Husk is a quite new golfing language, created by PPCG users Leo and Zgarb. It has begun being more and more competitive, often staying close or even beating languages known to be very terse, such as ...
18
votes
4answers
865 views

Tuple addition in pointfree

What is the shortest way we can express the function f(a,b)(c,d)=(a+c,b+d) in point-free notation? pointfree.io gives us ...
7
votes
1answer
186 views

Tips for Golfing in Standard ML

Standard ML (or golfier: SML) is a general-purpose, modular, functional programming language with compile-time type checking and type inference. (from Wikipedia) Though you almost certainly will never ...
7
votes
2answers
216 views

How to improve Ruby code under some restrictions

I'm (still) trying to make another submission to the Largest Number Printable question, and I've got the following bit of code: ...
1
vote
0answers
323 views

Trying to optimize a solution to a puzzle with PHP [closed]

I got inspired by this: Print every character your program doesn't have But with the exception that the letters have to be between ASCII 32 to 126. We started fooling around with it at the office ...
15
votes
1answer
984 views

How to reduce EXE size of x86 ASM compiled with FASM?

As an exercise, I've created a simple solution for this challenge, in x86 Assembly Language. I'm running this with FASM on Windows. Here's my source code: ...
15
votes
13answers
872 views

Tips for golfing in QBasic

What general tips do you have for golfing in QBasic? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to QBasic (e.g. "remove comments" is ...
10
votes
0answers
357 views

Tips for Golfing in SQLite?

I was looking for this page to help me enhance my first answer with SQLite, but I couldnt find one. So here we are! What general tips do you have for golfing in SQLite? I'm looking for ideas that can ...
13
votes
3answers
1k views

Advice for ruby

How can I shorten: p=gets.to_i a=gets b=gets.to_i If my input is an integer, followed by a string, followed by an integer?
12
votes
2answers
3k views

How can I shorten this python code?

Here is the code which I want to shorten. ...
3
votes
2answers
401 views

Golfing Newton's Method

I have the following code which I've written to emulate Newton's method for deriving the square root of a number: ...
82
votes
11answers
14k views

How on earth did llhuii output the Evil Numbers in 42 bytes of Python?

This is a tips question for golfing in Python concerning the Evil Numbers question on Anarchy Golf. An number is evil if its binary expansion has an even number of 1's. The challenge is to print the ...
4
votes
5answers
305 views

Tips for golfing in Proton

Proton is a quite new language created by PPCG user Hyper Neutrino. It is very similar to Python, and has similar syntax to the language Cheddar, hence there are some clever tricks you can use in ...
4
votes
3answers
311 views

Compare char to other chars in javascript

In my answer, I have this code: s.match(/[AEIOU]/) This seems too verbose to check if a string is one of A, ...
12
votes
1answer
3k views

Most common elements of a list in Python

This is a tips question for golfing in Python, which is on topic for main. I'm looking for the shortest way to get all of the most common elements of a list in Python, in the shortest way possible. ...
41
votes
31answers
5k views

Tips for golfing in x86/x64 machine code

I noticed that there's no such question, so here it is: Do you have general tips for golfing in x86/x64 machine code? If the tip only applies to a certain environment or calling convention, please ...
6
votes
2answers
183 views

lastIndexOf in CJam

For the question Find the highest unique digit , here is my answer : 9A,sqfe=W%X#- At the end I am essentially trying to achieve a lastIndexOf. I do that by ...
7
votes
1answer
543 views

Code Golfing Split String in Bash [closed]

Let us play a little golfing game. Given a single line of N space separated numbers from STDIN, one must output those numbers on N lines. So far, I came up with the three following bash solutions : ...
19
votes
10answers
1k views

SQL select number ranges

I found it quite hard to achieve a range of numbers as rows in MySQL. For example the range 1-5 is achieved by: ...
23
votes
7answers
1k views

Tips for golfing in Kotlin

Given Google's recent announcement of official Kotlin support for Android development, I thought it might be timely to poll the community for some awesome golfing tips for this relatively new JVM ...
1
vote
1answer
995 views

A+B using C++ language

I'm golfing a program to sum two numbers in C++. Example: 10 3 13 I found out that this problem can be solved in 54 symbols (without spaces and so on) using C++....
7
votes
2answers
235 views

Tips for golfing in V

What general tips do you have for golfing in V? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to V (e.g. "remove comments" is not an ...
16
votes
3answers
957 views

Are there any functional programming languages designed for code-golfing?

Are there any functional programming languages designed for code golfing? I know that golfscript and CJam fulfill the same category for stack based, but I couldn't find a functional code golfing ...
30
votes
14answers
3k views

Tips for golfing in TeX/LaTeX

What tips do people have for golfing in TeX/LaTeX? Please post one tip per answer, each at least somewhat specific to TeX/LaTeX. Context: I noticed this answer and that there is no tips question for ...
23
votes
12answers
3k views

General tips for representing large numbers

Sometimes, while golfing, one needs to represent large number(s) in their code. Writing them as is can significantly increase the byte-count. What general1 tips do you have for representing long ...
9
votes
1answer
468 views

Shortest way to generate 12 repeated characters in JavaScript

'---------' '-'.repeat(9) // longer! '------------' (x='----')+x+x '-'.repeat(12) // same length Is there any cleverer way of generating strings of 12 repeated ...
5
votes
1answer
182 views

Dump stack to array

I'm new to this code-golfing thing and I'm very interested in CJam. Is there a way to get all the current stack as an array? I think I can do it with something like ...
5
votes
2answers
1k views

How to simplify ternary expressions in Javascript

I have an expression that could be expressed as either of : a += (A ? B ? x : C ? y : D : D); a += (A && B ? x : A && C ? y : D); where A,B,C ...
22
votes
18answers
2k views

Tips for golfing in Japt

Now that I'm thoroughly addicted to Code Golf, it's probably about time that I try to pick up a few golfing languages. Given that I play almost exclusively in JavaScript, Japt seems like the logical ...
19
votes
7answers
3k views

Tips for golfing in 2D languages

What general tips do you have for golfing in 2 dimensional programming languages? I'm looking for tips which can be applied to code-golf problems and are specific to 2D programming languages, but not ...
5
votes
2answers
182 views

Tips for golfing in Mini-Flak

What general tips do you have for golfing in Mini-Flak? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Mini-Flak (e.g. "remove ...
6
votes
1answer
262 views

Further golfing this C# code from Scramble words while preserving their outlines

I'll start off by saying I checked and checked again that this question should be on topic. I will also clearly state that this is a tips question about further golfing a certain set of code not a ...
14
votes
4answers
785 views

Tips for golfing in ///

What general tips do you have for golfing in ///? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to /// (e.g. "remove unnecessary ...
17
votes
6answers
776 views

Tips for storage in a golfing language

I am writing a golfing language. Do you suggest variables, stack(s), tapes, registers, etc for storage in a code-golf language? What about implicit input? Rough definitions: A variable is simply a ...
7
votes
0answers
330 views

Tips for making a golfing language [duplicate]

I am currently working on a golfing language. Do you have any suggestions for this language? What are some helpful features of a good golfing language? What features do you find useful? Do you suggest ...
10
votes
4answers
261 views

Tips for golfing in Logo

Logo is a programming language that was designed back in 1967 that has great potential for creating graphics in relatively few bytes compared to other languages. Logo is an educational programming ...
5
votes
0answers
241 views

Golf this AP CS Java FRQ - Duplicate Sums of Arrays in 2D Array [closed]

In preparation for the AP Computer Science AP Test (Java), our teacher has been giving us FRQs from previous years for practice. My friend and I were golfing this during class today and got it as ...
7
votes
2answers
758 views

Tips for golfing in SOGL

Do you have any code-golf tips for writing in SOGL, a golfing language created by dzaima? Your tips should be at least somewhat specific to SOGL. Please post one tip per answer.
17
votes
12answers
867 views

Tips for golfing in Charcoal

Charcoal is a language created by ASCII-only and DLosc that specialises in ASCII art challenges. What tips do you have for golfing in Charcoal? Obviously I am looking for tips related specifically to ...

1 2
3
4 5
7