Linked Questions

40
votes
51answers
7k views

Cops: Make a regex - Make a snake

This is the cop's thread. The robber's thread is here. Write a code that takes an input n and creates a n-by-n "snake matrix". A snake matrix is a matrix that ...
29
votes
11answers
3k views

Asterisk spiral

Given the spiral of size S and the step N, output the "square" S*S spiral having ...
24
votes
14answers
1k views

Number Spiral Problem

A number spiral is an infinite grid whose upper-left square has number 1. Here are the first five layers of the spiral: Your task is to find out the number in row y and column x. Example: ...
22
votes
10answers
1k views

Roll the Alphabet into a Spiral

Write a program or function that, when given n, will print a spiral n characters long made up of the Latin alphabet ...
33
votes
8answers
935 views

Can square tree rings be generated from primes?

Apparently yes! In three easy steps. Step 1 Let f(n) denote the prime-counting function (number of primes less than or equal to n). Define the integer sequence s(n) as follows. For each positive ...
31
votes
7answers
2k views

pssssssssssssst

Introduction This is one is pretty straightforward. We will be drawing a snake in ascii. This was inspired by that old snake game where you have to collect the fruit and you continuously grow. ...
19
votes
8answers
775 views

Spiral neighbourhoods

If we take the natural numbers and roll them up counter clock-wise into a spiral we end up with the following infinite spiral: ...
6
votes
15answers
1k views

Alphabet Spiral

You are to write a program or function that outputs this exact text: OPQRSTU NQPONMV MREDCLW LSFABKX KTGHIJY JUVWXYZA IHGFEDCB May also be lowercase and trailing ...
15
votes
9answers
631 views

Roll the carpet

This question is inspired by Kevin Cruijssen's question. Now that the carpet is laid out, we want to roll it. Your task is to write a program that takes a string and returns a spiral made from this ...
12
votes
11answers
700 views

Square-unspiral the string!

Given a string, first square it as follows: First, write the string. abcde Next, write the string rotated one left. ...
6
votes
7answers
579 views

Determine the position of a non-negative number in the infinite spiral

Definition The infinite spiral used in this question has 0 on the position (0,0), and continues like this: ...
6
votes
5answers
334 views

Return Spiral Indexes!

Spirals are cool , so are numbers, and number spirals are even cooler. But what if I want a specific number, in a specific place using xy coordinates... Challenge Using an infinite spiral moving ...
8
votes
4answers
181 views

Flattened Spiral Permutation Index

Context Consider square matrices with n columns and rows containing the first n^2 (i.e. n ...
4
votes
4answers
119 views

Given a grid, starting at the center and spiraling out, and an Position what is the ID?

Related: Determine the position of a non-negative number in the infinite spiral Wind me a number snake! Challenge: Given a grid, with an ID starting at the center and spiraling out, what is the ID ...
1
vote
0answers
73 views