Tips for either golfing or programming challenges. In most current cases it is for helpful tips and tricks how one could golf more effectively with a particular language.

learn more… | top users | synonyms (1)

6
votes
1answer
59 views

Tips for golfing in Swift

What are some tips for code-golfing in Swift? Its focus on safety seems to make it difficult to golf in, but that makes little tips and even more useful. Are there any features in Swift that may help ...
11
votes
7answers
1k views

Tips for golfing in Jolf

Jolf is a procedural golfing language made by @CᴏɴᴏʀO'Bʀɪᴇɴ. What tips do you have for golfing in Jolf? Please post one tip per answer. These tips should be at least somewhat specific to Jolf, ...
4
votes
5answers
105 views

Tips for golfing in PARI/GP

PARI/GP is a free computer algebra system. It is designed for (algebraic) number theory, not golfing, but that's part of the attraction. Unsurprisingly, it fares best at mathematical tasks; its ...
9
votes
5answers
140 views

Tips for golfing in MATL

MATL is a golfing language created by Luis Mendo. MATL has proven to be highly competitive, often beating submissions in other golfing languages such as Pyth, CJam and Jelly. What are some useful ...
7
votes
3answers
281 views

How can I shorten this python code analyzing a 3d grid?

My Python 3 function golf(...) should take a list of lists of lists of strings representing a solid cube and return whether there are any places in which two equal strings are directly next to each ...
7
votes
4answers
110 views

Tips for golfing in dc

What general tips do you have for golfing in dc? dc is a calculator utility for UNIX/Linux that predates the C language. I am interested in how to make my dc programs (calculations?) shorter. I'm ...
4
votes
1answer
308 views

Need help golfing Python 3 code to calculate volume & surface of spheroids in <150 bytes

I want to write a function golf(C, A) that takes the height (C = 2*c) and the width (A = 2*a) of an oblate (left image) or prolate (right image) spheroid or a sphere as parameters and returns the ...
-1
votes
0answers
44 views

Tips for King of the Hill challenges [migrated]

Inspired by this question, what are some tips you guys have for creating king of the hill challenges? What are some things to keep in mind in the planning and implementing of the rules and the ...
4
votes
4answers
96 views

Tips for golfing in Racket / Scheme

What general tips do you have for golfing in Racket / Scheme? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Racket / Scheme (e.g. ...
9
votes
3answers
214 views

Tips for King of the Hill bots [closed]

What general tips do you have for creating a bot to participate in a King of the Hill challenge? What strategies do you use to go from considering the challenge to creating your bot? What data ...
3
votes
10answers
154 views

Tips for golfing in Factor

What general tips do you have for golfing in Factor? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Factor (e.g. "remove comments" is ...
1
vote
2answers
45 views

Tips for golfing in Pike

Pike is a dynamically typed interpreted scripting language, heavily influenced by C, which typically compiles to C99 with a few #defines. (It even has a preprocessor!) What general tips do you have ...
7
votes
8answers
228 views

Tips for golfing in D2

What general tips do you have for golfing in D? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to D (e.g. "remove comments" is not an ...
7
votes
1answer
81 views

Tips for golfing in Rust

While Rust is very, very rarely competitive in code golfing competitions (Java is often shorter), it can still be fun to golf in. What are some tricks for making Rust code shorter? Please post only ...
4
votes
3answers
235 views

Shorter way to assign a default value to the standard output stream

I have this code : tr ' ' '\n'|sort -n|head -1 The code is pretty simple, it takes a list of integer in the standard input stream (like 5 9 8 7 5 2 -12 -30), it sort the integers and display only ...
5
votes
3answers
161 views

Tips for Golfing in Vitsy

While there are only a few users of the Vitsy programming language right now, I wish to create a place for tips for golfing in Vitsy. What general tips do you have for golfing in Vitsy? I'm looking ...
7
votes
2answers
139 views

Tips for golfing in Retina

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

Generating the alphabet in JavaScript

I'm pretty sure there's not a better way to do this but figured it couldn't hurt to ask. I'm tired of typing out a='abcdefghijklmnopqrstuvwxyz'. Cool languages have Range('a'..'z') or similar What ...
15
votes
6answers
220 views

Tips for golfing in vim

I've recently realized how vim works great for golfing, especially for kolmogorov-complexity. Also, according to meta vim is a perfectly acceptable 'programming language' at least, for the scope of ...
22
votes
7answers
1k views

Tips for golfing in Jelly

Jelly is a tacit, golf-oriented programming language by our very own Dennis. It’s popping up in answers here more and more often, beating other golf-y languages like Pyth and CJam, both by using its ...
2
votes
0answers
68 views

Tips for golfing in Subleq

Subleq is a programming language with only one instruction. Each instruction contains 3 parameters. Code and data space is the same. How it works: A B C A, B and C are signed ints. Instructions are ...
12
votes
4answers
363 views

Strategies for representing a given large integer using arithmetic expression

I have a specific number in mind, but it's part of a challenge I'm doing, and I don't want people to do (all) the work for me. Here is a number which has the same digits, but shuffled: ...
5
votes
2answers
106 views

Tips for golfing in Forth

What general tips do you have for golfing in Forth (and its clones)? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Forth (e.g. ...
7
votes
5answers
138 views

Tips for golfing in Prolog

What general tips do you have for golfing in Prolog? I am looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Prolog (e.g. one letter ...
6
votes
3answers
142 views

Tips for golfing in Elixir

Elixir is a relatively new functional language, which I've taken a deep interest in. I'd like to get general tips about golfing in Elixir and learn techniques that can be applied to code-golf problems ...
1
vote
2answers
130 views

Negate a condition if a bool is FALSE [closed]

Let's say I have a condition expression x and that I want to check if it is TRUE or FALSE depending on the value of a boolean y: y ? x : !x Is there a way to express it without repeating x ...
6
votes
1answer
76 views

Tips for golfing in Burlesque

This serves as a catalog for tips related to golfing in Burlesque. Burlesque is a lazy, esoteric programming language. It's mostly used on anarchy golf while popularity on Codegolf is not as high. ...
2
votes
1answer
158 views

How could Stringy be improved? [closed]

I created a programming language for manipulating strings called Stringy. It's very different from other programming languages, since you only have one string (for manipulation) and some variables. ...
1
vote
2answers
177 views

Shortening str.replace() [duplicate]

In Python it is often necessary to use str.replace(a,b), however .replace is rather long and feels unnecessary. So is there a shorter alternative to str.replace. Alternatively is there a similar ...
23
votes
9answers
3k views

How can Pyth be improved? [closed]

Pyth is in ongoing development, meaning that new features are being added all the time. I want to make Pyth a better langauge, so I'd like to know what features people are looking for. This is the ...
3
votes
3answers
239 views

Returning the range of a number as a palindrome

I like to do programming challenges in my free time to teach myself and keep fresh, this one I can't seem to optimize though and it's driving me insane. The goal is essentially, "Given a number, ...
-2
votes
1answer
188 views

Python Golfing Suggestions [closed]

I have read: Tips for golfing in Python I would like to golf this code further. Any more tips? x,y,q,w=[int(i) for i in raw_input().split()] while 1: a=int(input()) s=d="" if q>x: s="W" ...
18
votes
2answers
574 views

Golfing Strings

I have always failed to give an answer for kolmogorov-complexity challenges which require string compression, the main reason being that I don't know to use string compression tools as effectively as ...
6
votes
3answers
827 views

What is the shortest infinite loop statement?

I'm working on a golf for Java and I need an infinite loop. Obviously, I don't want to spend any more bytes than I have to, especially in such an expressive language. Assuming I have some code I want ...
9
votes
1answer
435 views

Shortening a long number

When dealing with long numbers when code golfing, getting the length of your code down can be difficult, so do you have any tips for making a number shorter and easier to manage? For example, the ...
5
votes
0answers
117 views

Tips for golfing in INTERCAL

What general tips do you have for golfing in INTERCAL? I'm looking for ideas which can be applied to code golf challenges and are also at least somewhat specific to INTERCAL (i.e. "remove comments" is ...
6
votes
10answers
217 views

Tips for golfing in CoffeeScript

What tricks do you know to make CoffeeScript code shorter? CoffeeScript is language that compiles into JavaScript ("transpiles" into ES3, to be exact). The golden rule is "It's just JavaScript", ...
6
votes
3answers
834 views

GolfScript, CJam, or Pyth? [duplicate]

Which language usually produces shorter golfed code: Pyth, CJam or Golfscript? In asking this, I do not mean which has a prettier syntax or which has the most useful commands, I mean overall, which ...
7
votes
1answer
213 views

Golfing with User Agents

Usually when performing an internet challenge, there's no problem with having to specify a user agent, but when it comes to dealing with Google, it changes. Google blacklists the Urllib user agent, ...
2
votes
0answers
112 views

Golfing Delayed Expansion Variables in Batch

Enabling delayed expansion variables in Batch chews up a lot of bytes. The shortest I have managed to make it is: @!! 2>nul||cmd/q/v/c%0&&exit/b Saving 11 bytes over @echo ...
13
votes
1answer
550 views

Golfing with Python Import

When is it beneficial to use inline, single use importing in Python? For example: __import__("x").doSomething() Is the above ever shorter than the below? import x x.doSomething() Or from x ...
6
votes
3answers
886 views

Convert a string representation of a number to int[] in C#

What is the shortest C# statement that will convert a string representation of a number to an int[] that contains each digit? string number = "1234"; number.Array.ConvertAll(line.ToCharArray(), c ...
2
votes
1answer
152 views

all non-empty sublists partitionings of a list

I had to write a code for finding all non-empty sublists partitionings of a list: def f(s): if s: for j in range(1,len(s)+1): for p in f(s[j:]): yield ...
16
votes
10answers
664 views

Tips for golfing in TI-BASIC

What general tips do you have for golfing in TI-BASIC for the TI-83/84+ series calculators? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat ...
10
votes
2answers
591 views

Best place for learning GolfScript? [closed]

It looks like a fun language, but the official site is down and the EsoLangs page doesn't explain it quite well and looks like it's missing stuff. Is there anywhere that the language is documented?
12
votes
8answers
546 views

Tips for golfing in sed

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

Improving a Rubik's Cube scrambler's byte count

Okay, I recently wrote a Javascript Rubik's Cube scrambler that outputs a 25-move scramble. It's 135 bytes. The Gist is here, but for reference, I have the formatted code: function(){ ...
12
votes
3answers
933 views

Is there a shorter way to get user input in python?

This is not a challenge. I'm wondering if it's at all possible to get user input into two separate variables in python (2 or 3) with less than 19 bytes. These are all the shortest I can get: ...
7
votes
2answers
383 views

Generalized integer casting in Python

Background I have a string in Python which I want to convert to an integer. Normally, I would just use int: >>> int("123") 123 Unfortunately, this method is not very robust, as it only ...
3
votes
1answer
222 views

Minimum of a Polynomial in Python

What is the shortest amount of code that can find the minimum of an inputted polynomial? I realize that you can import packages like Numpy and others, but using only user defined functions, what is ...