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)

3
votes
1answer
46 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 ...
21
votes
5answers
906 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
60 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 ...
11
votes
4answers
248 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: ...
4
votes
2answers
93 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. ...
5
votes
4answers
94 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
129 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
127 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
73 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
151 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
158 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 ...
24
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 ...
2
votes
3answers
225 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
143 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
568 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 ...
5
votes
3answers
738 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
428 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
111 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
206 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", ...
4
votes
3answers
736 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
210 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
105 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
508 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
708 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
145 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
631 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
582 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
527 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
142 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
881 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
358 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
214 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 ...
11
votes
6answers
355 views

Tips for golfing in K

K is a programming language in the APL family designed by Arthur Whitney. While the official interpreter is closed-source and commercial, a trial version with a workspace limit of 32 bits of ...
9
votes
4answers
322 views

Tips for golfing in LOLCODE

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

Tips for golfing in Befunge 93 [duplicate]

What general tips do you have for golfing in Befunge 93? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Befunge 93 (e.g. "remove ...
1
vote
1answer
373 views

How can I use cmp(a,b) with Python3?

I want to compare a and b. How can I use cmp(a,b) with Python3 ?
5
votes
4answers
451 views

How could I reduce the length of this code?

I need to reduce the length of this code in Python 3 as much as possible (even if it will be less readable): a,b,x,y=[int(i) for i in input().split()] while 1: r='' if y<b:r='S';y+=1 if ...
9
votes
1answer
757 views

Concatenate lists of strings item-wise in Python

This is a tips question for golfing in python. Suppose you have two lists of strings, and you want to concatenate the corresponding entries from each list. E.g. with a=list("abcd") and ...
-1
votes
1answer
166 views

How can I rename .split or .join in python? [duplicate]

I can rename a built in module like this: r=range list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] but whenever I rename .split, I get an error: s=split NameError: name 'split' is not defined How ...
5
votes
3answers
835 views

Leibniz golf in C#

I'm starting with golf code. But im only do C# so I know wont be a breaking record, but I want give it a try. Leibniz Challenge is here The first line contains the number of test cases (N) which is ...
5
votes
4answers
138 views

Tips for golfing in Element

Since my use of Element has increased recently, I am interested in tips for golfing programs written in it. What general tips do you have for golfing in Element? I'm looking for ideas that can be ...
21
votes
3answers
486 views

Tips for golfing in The Shakespeare Programming Language

What general tips do you have for golfing in The Shakespeare Programming Language? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to SPL ...
6
votes
2answers
276 views

Tips for golfing in whitespace

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

Is there a shorter way to assign one of two variables in Python?

This is a tips question for golfing in python. In multiple golfs I've done in Python, a fixed value is assigned to one of two variables chosen by a Boolean. The chosen variable is overwritten by the ...
29
votes
15answers
3k views

Tips for Regex Golf

Similar to our threads for language-specific golfing tips: what are general tricks to shorten regular expressions? I can see three uses of regex when it comes to golfing: classic regex golf ("here ...
12
votes
1answer
1k views

Am I code-golfing properly?

I am curious if I am Code Golfing properly. I set the challenge for myself to make a small hashing program into a single statement in Python. I first started off with: from itertools import ...
8
votes
6answers
853 views

Tips for golfing in ><> (Fish)

Since I've been seeing more ><> submissions floating around lately, I thought it might be a good idea to have a tips page. Please stick to one tip per post, unless they are closely related. ...
8
votes
1answer
1k views

Python 3 - Tried Golfing My Assignment

Note: This isn't as much a golfing challenge; it is more so asking for golfing suggestions. Recently I had a Python assignment for my web development class, in order to check whether we could code. ...
1
vote
2answers
275 views

Code Golf: Leibniz Series

This is the same question as Solve the CodeSprint4 Leibniz code golf challenge in Python in 66 characters. The variation is that I'm a C programmer. My code for the above question is: #include ...
5
votes
2answers
430 views

C golfing tips - returning 0 without return statement

I'm looking for some solution in returning values in main function, I need to shorten my program more, return 0 takes too much characters of my code, I need to return 0, or my code fails. I know that ...