Linked Questions

306
votes
161answers
113k views

Tips for golfing in Python

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

Print a Tabula Recta!

The Tabula Recta (sometimes called a 'Vigenere Table'), was created by Johannes Trithemius, and has been used in several ciphers, including all variants of Bellaso's Vigenere cipher and the Trithemius ...
156
votes
57answers
32k views

Tips for golfing in C

What general tips do you have for golfing in C? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C (e.g. "remove comments" is not an ...
90
votes
122answers
17k views

Print this diamond

This question has been spreading like a virus in my office. There are quite a variety of approaches: Print the following: ...
44
votes
160answers
12k views

Scream very loudly

Write a script that outputs A to stdout infinitely. There shold be no newlines or seperators between the characters Standard loopholes apply This is code-golf. ...
97
votes
45answers
31k views

Implement the Thanos sorting algorithm

The sorting algorithm goes like this: While the list is not sorted, snap half of all items (remove them from the list). Continue until the list is sorted or only one item remains (which is sorted by ...
24
votes
61answers
9k views

Find the longest word in an array

Your challenge is to take an array of strings and output the longest string in the array. So for ["tiny", "small", "bigger", "biggest"] the output would be ...
41
votes
43answers
4k views

Decode the string

This is my first challenge on ppcg! Input A string consisting of two different ascii characters. For example ABAABBAAAAAABBAAABAABBAABA Challenge The task is ...
40
votes
43answers
5k views

Find the needle in the haystack

Given a rectangular haystack of size at least 2x2 composed of all the same printable ASCII characters, output the location (counting from the top-left) of the needle which is a different character. ...
21
votes
55answers
6k views

Sort odd numbers first

Rearrange a given list such that all the odd numbers appear before all the even numbers. Besides for this requirement, the output list may be in any order. The input will only contain integers, but ...
28
votes
41answers
3k views

Subtract the next numbers

Description Subtract the next P numbers from a N number. The next number of N is N + 1. Look at the examples to get what I mean. Examples: ...
40
votes
26answers
3k views

Difference should make no difference

Your company lately hired a new bunch of extremely dedicated sysadmins. They feel that just watching computer screens is quite limiting (I mean, 60Hz refresh rate is just NOT enough), so they hooked ...
46
votes
19answers
10k views

Can Pac-Man Eat This String?

In the arcade version of the game, Pac-Man eats pac-dots. However, in this challenge, he's hungry for alphanumeric characters and punctuation in a string. Your task is to create a function that feeds ...
27
votes
30answers
1k views

Element-wise string multiplication

Inspired by this challenge (thanks @cairdcoinheringaahing for the title!), your task is to take two printable ASCII strings and multiply them element-wise with the following rules. How does it work? ...
43
votes
17answers
2k views

Generate the Temple Skyline Sequence

Consider the following process: Take some non-negative integer N. e.g. N = 571 Express it in binary with no leading zeroes. (Zero itself is the only exception, ...
17
votes
33answers
3k views

Tips for golfing in VBA

Similar to this, this, and this question... What general tips do you have for golfing in VBA? I'm looking for ideas that can be applied to code golf problems in ...
15
votes
26answers
2k views

Make every other vowel uppercase

Given a lower case string. Ex: s = 'abcdefghijklmnopqrstuvwxyz' The goal is to make every other vowel uppercase. Desired output here: ...
18
votes
32answers
2k views

Fill out my Bubble Sheet

Today was AP exam registration day at my school, and while I was meticulously bubbling in the pages and pages of information required, the idea for this challenge hit me. So, given a string of letters ...
32
votes
14answers
4k views

Solve the Global Debt, the Code Golf way

The leaders of the world have met and have finally admitted that the best (and only) way of resolving global economic woes is to take stock of how much they owe each other and just pay each other off ...
21
votes
20answers
2k views

Reorder a matrix, twice

You are given a square \$n \times n\$ matrix \$A\$, and a list (or vector) \$u\$ of length \$n\$ containing the numbers \$1\$ through \$n\$ (or \$0\$ through \$n-1\$). Your task is to reorder the ...
18
votes
16answers
3k views

Stack Exchange Answerer

Oof! You've been coding the whole day and you even had no time for Stack Exchange! Now, you just want to rest and answer some questions. You have T minutes of free time. You enter the site and see N ...
13
votes
15answers
3k views

Pick the longest stick

You are a young programming geek living with your 2 other best friends. Every week, one of you has to do all the chores of the house and you decide whose turn it is by picking a stick. The one who ...
23
votes
5answers
735 views

Follow incomplete directions

A friend of yours has given you directions to the best restaurant in town. It's a series of left and right turns. Unfortunately, they forgot to mention for how long you need to go straight ahead ...
26
votes
3answers
2k views

Residue Number System

In the vein of large number challenges I thought this one might be interesting. In this challenge, we will be using the Residue Number System (RNS) to perform addition, subtraction, and ...
0
votes
0answers
250 views

Reduction of source code of a program [duplicate]

Possible Duplicate: Sum of positive integers. (Spoj - SIZECON) Here is the question:- Given the set of integers, find the sum of all positive integers in it. Input t – number of test cases [t <...