All Questions
13
votes
12answers
455 views
The Snail in the Well
Background
There's a common riddle that goes something like this:
A snail is at the bottom of a 30 foot well. Every day the snail is able to climb up 3 feet. At night when they sleep, they slide ...
7
votes
6answers
265 views
Tri-interquine - Three programs that output each other in a loop
Related: Interquine
Program A outputs program B's code when run, and B outputs C's source, and C outputs A's source.
This time you can't exchange two characters and exchange again :)
Requirements:
...
0
votes
0answers
27 views
Say What You Saw [duplicate]
Background
The background comes from this related challenge. Thanks, @HeyLlama!
The "Look and say" or "Say what you see" sequence is a series of numbers where each describes the last.
1
11 (one one)...
0
votes
0answers
24 views
Describe a number with numbers (Looping) [duplicate]
Overview
Related.
When you have a very long number, you would like to say how many of a specific digits are there rather than the number itself. You may want to repeat this multiple times. Write a ...
7
votes
14answers
399 views
Reduce the list to a final number
Inputs
A list (array) of numbers, or numerical strings if that makes it easier. You can assume there will always be at least two elements in the list and every element will be a natural number (...
-1
votes
0answers
39 views
Let's code a faster combination generator for R [on hold]
Some days ago I found that R combn function is very slow.
That function it's used to generate all combinations of the elements of x taken m at a time.
I was specially interested in m = 2.
Then I ...
14
votes
20answers
799 views
The sum of consecutive odd numbers
Although related challenges have been asked, this one is different to warrant its own question.
Challenge
Given a positive integer, return the longest sequence of consecutive positive odd integers ...
9
votes
19answers
645 views
A Simple Patttern
Inputs:
Two single digits (let's call them m and n) and two chars (let's call them a and b) in your input format of choice.
Output:
For the walkthrough, pretend m=2, n=5, a='a', b='b'.
Your output ...
13
votes
6answers
710 views
n * k = dd0d00d where d = …?
Given a positive integer n ≤ 500:
Find the smallest positive integer k such that all digits in the decimal representation of n*k are either 0 or d, with 1 ≤ d ≤ 9.
Print or return d in less than 30 ...
14
votes
10answers
1k views
Reverse a Rubik's Cube Algorithm
Whenever you make a move on a Rubik's Cube, there is a reverse move which undoes the first move. Because of this, every algorithm (set of moves) has a reverse algorithm which undoes the first ...
10
votes
13answers
1k views
Clark's Triangle
Ok I've been on a bit of a triangle kick recently so here's another one.
Clark's Triangle is a triangle where the leftmost entry of each row is 1 and the rightmost entries are made up of multiples of ...
4
votes
0answers
197 views
Code Golfing Split String in Bash
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 :
...
28
votes
3answers
1k views
Sheet music ASCII-art generator
Note: Anders Kaseorg warns me that this could be a duplicate of another previous question. It seems so, and I'm sorry I did not find that question before posting this one. Nonetheless, that question ...
21
votes
28answers
2k views
Smallest multiple being run of 9 followed by optional run of 0
Given a positive integer, find its smallest positive integer multiple which is a run of 9 followed by an optional run of 0. In other words, find its smallest positive integer multiple which is matched ...
20
votes
14answers
2k views
Pascal's Rhombus
Pascal's Rhombus (which is actually a triangle) is obtained by adding in the pattern:
*
***
x
instead of
* *
x
This means that each cell is the sum of the three cells on the row directly ...
14
votes
42answers
2k views
Compare the averages of my lists
Getting the average of a list (e.g [2,6,7])
Get the length of the list: [2,6,7] -> 3
Sum the numbers in the list: 2 + 6 + 7 = 15.
Divide the sum by their count: 15 / 3 = 5.
You should compare ...
-3
votes
0answers
103 views
Print your answer [duplicate]
You must write code to print out your answer. The answer must include the following: Your code, byte count, name of language and the formatting style of my example (H1 header for bytecount/language ...
19
votes
3answers
243 views
Rectangular difference
In this challenge, you are given two overlapping rectangles, and you need to calculate the rectangles created by removing one from the other.
For example, if you remove the red rectangle from the ...
13
votes
39answers
2k views
What is the standard scratch?
In golf, the standard scratch of a course is calculated using this formula:
(3*num_of_3_par_holes + 4*num_of_4_par_holes + 5*num_of_5_par_holes) - difficulty_rating
Your task is to calculate the ...
15
votes
6answers
870 views
BASKETBALL FRVR?
You might already be familiar with the game: Basketball FRVR in facebook. There are two types of score you can make:
A virgin-shot:(we call it so in our country :D) When the ball enters the basket ...
61
votes
10answers
13k views
Regex, Paper, Scissors, Lizard, Spock
Warm up: Regex, Paper, Scissors
This is the challenge I originally wanted to post, before realising that some very short solution exist. Nevertheless, it can be an interesting problem to think about ...
19
votes
14answers
4k views
Counting from 1 to n without any consecutive numbers
Goal
You are given an integer n (n > 1). You must output how many permutations of the integers 1 to n there are which start at 1, end at n, and don't have two consecutive integers which differ by ...
16
votes
12answers
2k views
It was just an input-bug
Continuing my It was just a bug challenge:
Input:
A string consisting of printable ASCII characters without white-spaces nor new-lines.
Output:
First turn the input into a palindrome by reverting ...
15
votes
10answers
1k views
Compress a sparse matrix
Compress a sparse matrix using Compressed sparse row (CSR, CRS or Yale format).
These are all the same form of compression (ignore new Yale).
Input may be any 2d data structure (list of lists, etc): ...
-5
votes
8answers
237 views
“Hello, World”, Even before it runs
Warning: This challenge is only valid for languages with a compiler.
Make a program (which is perfectly valid code) that outputs Hello, World, even before runtime.
How? Let me explain.
Many ...
-5
votes
0answers
44 views
How to Compare Waterfall VS Incremental VS Spiral VS ROD Software Development Model? [on hold]
How we can compare Waterfall VS Incremental VS Spiral VS ROD Software Development Model ?
in following categories
Planning in early stage
Handle Large-Project
Detailed Documentation
Software House ...
7
votes
1answer
133 views
Cyclic Polyglot Challenge (Cops)
Cyclic Polyglot Challenge
This is the cops thread. You can find the robbers thread here.
Cyclic Polyglot
A N-element cyclic polyglot is a complete program that can be run in N different languages. ...
5
votes
1answer
83 views
Cyclic Polyglot Challenge (Robbers)
Cyclic Polyglot Challenge
This is the robbers thread. You can find the cops thread here.
Cyclic Polyglot
A N-element cyclic polyglot is a complete program that can be run in N different languages. ...
14
votes
23answers
1k views
Swap letter and digit runs
Given an input string containing only alphanumeric ASCII characters and starting with a letter, swap each letter run with the digit run which follows.
A run is a sequence of consecutive letters or ...
14
votes
2answers
301 views
Show me some fireworks!
Given, in any way and order,
dimensions (in whichever order you want)
a probability (in whatever format you want)
number of iterations (you may choose whether to count the initial state or not)
do ...
-1
votes
4answers
94 views
Generate a box based on user input [duplicate]
NOTE: This question is different than Draw an ASCII Rectangle because the user has to input only 1 number to generate a box, unlike the other question, where the user has to input the x and y size of ...
22
votes
14answers
2k views
Turn a string inside out
A balanced string is a string of parentheses () so that every parenthesis is can be matched with another one. More rigorously they are the strings spanned by this grammar:
S → (S)S | ε
We can turn ...
13
votes
8answers
2k views
Fewest operations to 100
Overview
Given a list of digits, find the fewest operations to make 100
Input
A string of digits, which may or may not be in numerical order. The order of the digits cannot be changed, however plus ...
24
votes
21answers
2k views
Is it a Lynch-Bell number?
You will be given a positive, whole number (that will never contain a 0) as input. Your task is to check whether it is a Lynch-Bell number or not.
A number is a Lynch-Bell number if all of its digits ...
26
votes
15answers
3k views
Interquine - Two programs that output each other in a loop (No cheating)
Program A outputs program B's code when run, and B outputs A's source.
Requirements:
Only one language across both programs
Programs are different. One program that outputs itself does not qualify. ...
-5
votes
0answers
45 views
How to create a search Engine with php and a xml database? [on hold]
How can I create a search engine with php and xml database? (I want to use SimpleXMLElement() function).
-13
votes
15answers
142 views
Shortest program that calculates the length of a number (C preferred)
The question is very simple:
Given a number between 0 and 999999999 and output its length.
Although it's simple, I'm looking specifically for a whole program written in C (and I will accept it). ...
21
votes
12answers
864 views
Pad a matrix with its sums
Challenge:
Given a square input matrix A, pad the matrix with one row and one column on all four sides.
The value of each element in the top and bottom row should be the sum of the elements in each ...
20
votes
9answers
4k views
Compute the inverse of an integer modulo 100000000003
The task is the following. Given an integer x (such that x modulo 100000000003 is not equal to 0) presented to your code in any way you find convenient, output another integer y < 100000000003 so ...
13
votes
16answers
853 views
Capped string ladder
Given a string s and a positive integer N, gradually duplicate each character more and more until N duplicates, and then staying at N duplicates until N characters away from the end, then step down ...
33
votes
13answers
3k views
Will I tip over?
Overview
Given a 3 line string, figure out if the structure falls to the left, balances, or falls to the right.
Input structure
You can imagine the structure as metal rod with stuff on top, all ...
9
votes
5answers
538 views
Increasing Goldbach partitions
The Goldbach conjecture states that:
every even number that is greater than 2 is the sum of two primes.
We will consider a Goldbach partition of a number n to be a pair of two primes adding to n. ...
30
votes
44answers
4k views
Am I divisible by double the sum of my digits?
Given a positive integer as input, your task is to output a truthy value if the number is divisible by the double of the sum of its digits, and a falsy value otherwise (OEIS A134516). In other words:
...
33
votes
23answers
2k views
Make a super acrostic
Background
Celebrating the release of Dyalog APL 16.0, where the solution to this problem is {⊢⌺(≢⍵)⊢⍵}Explanation
Task
Given a printable ASCII string of odd length n, make an n × n square with the ...
2
votes
8answers
176 views
Calculate the middle number of a row of the pascal triangle [duplicate]
Write a function that calculates a row of the pascal triangle and returns the middle number, if there are 2 it should return their sum.
Example:
5
would return
20
Example 2:
4
would return
6
...
1
vote
1answer
131 views
Quine over network [on hold]
Write a program, that sends its own source code over network.
Network example is TCP/UDP or web socket. Ethernet, Bluetooth, Wi-Fi and internet over USB are allowed.
No need to write receiver ...
-1
votes
0answers
59 views
How to check if internet is available? [on hold]
// example from: // https://msdn.microsoft.com/en-us/library/windows/desktop/ms737591(v=vs.85).aspx #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <winsock2.h> #include <...
57
votes
51answers
10k views
It was just a bug
Inspired by the bugged output in @Carcigenicate's Clojure answer for the Print this diamond challenge.
Print this exact text:
1 2 3 4 5 6 7 8 ...
20
votes
14answers
2k views
Spanish ID card control character calculator
This is a very very simple algorithm, that I am sure can be solved in many many different languages. In Spain ID cards (known as DNI) consist of 8 numbers and a control character. The control ...
10
votes
14answers
1k views
12 hour time conversion
Challenge
Convert and print out a time in a 12-hour format. HH:MM AM/PM
Examples
Input:
'Fri Jun 30 2017 21:14:20 GMT-0700 (PDT)'
'Fri Jun 30 2017 00:10:23 GMT-0700 (PDT)'
'Fri Jun 30 2017 12:10:...