# Tagged Questions

Problems relating to graph theory

5k views

### 40 Numbers in 9 Bytes

There are 40 ways a directed Hamiltonian path can be arranged on a 3×3 grid: This graphic (thanks Sp3000!) shows only the 20 undirected paths. Traverse each colored line in both directions for ...
224 views

### Play a Perfect Game of 4x4 Hex

Background Hex is a two-player abstract strategy game played on a K×K rhombus of hexagonal tiles. Two opposite sides of the rhombus are colored white, and the other two black, and the two ...
352 views

### Is My Graph Planar?

Your task is to determine whether a graph is planar. A graph is planar if it can embedded in the plane, or in other words if it can be drawn without any crossing edges. Input: You will be given an ...
133 views

### Map of Islands (and a river)

Introduction For many centuries, there has been a certain river that has never been mapped. The Guild of Cartographers want to produce a map of the river, however, they have never managed to succeed ...
2k views

### Where should I put my restaurant?

You are the owner of a restaurant. You are opening in a new area in Cartesia where there is only one main road, known as the y-axis. You want to place your restaurant such that you minimize the total ...
257 views

### Save the Geese from Extinction

The species of geese known as Alex A are known for residing in triangular grids consisting of 64 cells: (Picture taken from this unrelated Project Euler problem.) We'll label each cell with the ...
333 views

669 views

### Undirect a Graph

Introduction In this challenge, you are given a directed graph with self-loops, and your task is to convert it to an undirected graph without self-loops. Input Your input is a directed graph with ...
414 views

### Is This a Real Tree?

You should write a program or function which receives a string as input and outputs or returns if the input is an ASCII tree. _ \/ / \_/ | | ASCII trees consist of characters / \ | _ spaces ...
275 views

### Slime Molds Can Count!

Background Slime molds are awesome. If you place them on a surface with food sources, they will spread their tendrils to find the food, after which they form a network of connections between the ...
333 views

### Decide existence of total orderings

In this task, we consider arrays of positive integers such as this: 3 18 321 17 4 4 51 1 293 17 The input comprises a pair of such arrays both of arbitrary, possibly distinct, positive length. ...
3k views

### Infinite Labyrinths

Background You are the apprentice of a powerful wizard, and your master is currently developing a spell for creating an inter-dimensional labyrinth to trap his enemies in. He wants you to program his ...
166 views

### Count Maximal Fence Arrangements

Background I want to build a fence. For that, I have collected a bunch of poles, and stuck them to the ground. I have also collected lots of boards that I'll nail to the poles to make the actual ...
314 views

### Downhill Maze Solver

A downhill maze is given as a series of rows of space separated digits from 0 to 9 inclusive, plus one "S" and one "X", where the S denotes the start and the X denotes the finish. In a downhill maze, ...
659 views

### fourth grade math homework for the week: a most inefficient traveling salesman

My daughter had the following assignment for her math homework. Imagine six friends living on a line, named E, F, G, H, J and K. Their positions on the line are as indicated (not to scale) below: ...
331 views

### Total number of topological sorts

For a given DAG (directed acyclic graph), each of its topological sorts is a permutation of all vertices, where for every edges (u,v) in the DAG, u appears before v in the permutation. Your task is ...
515 views

### Grow words from fertile vocabularies

An incremental word chain is a sequence of words of a vocabulary such that each word is the result of either prepending or appending a single character to the previous word, ignoring capitalization. ...
878 views

### Building a long chain of words

This challenge is to find the longest chain of English words where the first 3 characters of the next word match the last 3 characters of the last word. You will use an common dictionary available in ...
1k views

### Construct a graph

In this challenge, your task is to construct an undirected graph from a sequence of directives. There is one directive for each nonnegative integer, and each transforms a given graph into a new one. ...
2k views

### Can maze be solved?

The puzzle Print 0 if a maze n*m can not be solved Print 1 if a maze n*m can be solved (in 1 or more ways) (so I'm not asking for paths but if it's possible to solve!!!) Input array(2d): ...
300 views

### 3x3 Connected Components

The Challenge Consider the 3x3 king grid, as shown in the following ASCII graphic: A--B--C |\/|\/| |/\|/\| D--E--F |\/|\/| |/\|/\| G--H--I You are given as input a length-9 list of integers that ...
525 views

### Four color theorem

The Four color theorem States that no more than four colors are required to color the regions of a map. The challenge Given a list of State borders assign each state ID a color so that no two ...
284 views

### Edge Elimination Number

From Erich Friedman's Math Magic, (problem #2 on that page) your challenge is to find the edge elimination number of a connected graph. A single edge elimination is the removal of an edge from a ...
2k views

### Create xkcd-Style Narrative Charts

In one of the more iconic xkcd strips, Randall Munroe visualised the timelines of several films in narrative charts: (Click for larger version.) Source: xkcd No. 657. Given a specification of the ...
692 views

### Sabotage a Train to Make It Run Late

"I want to go to the Araby bazaar to buy a present for the one I have fallen in love with. However, if I arrive too late all the stores will be closed and I won't be able to buy anything. Can you help ...
5k views

### Your car only turns right!

Introduction You have the misfortune of being stuck in a runaway car on an obstacle course. All of the car's features are non-responsive, save for the steering system, which is damaged. It can ...
638 views

### Find the Chromatic Number

Surprisingly, we haven't had any challenges on graph colouring yet! Given an undirected graph, we can give each vertex a colour such that no two adjacent vertices share the same colour. The smallest ...
1k views

### How to slow down a drunkard on his way home

Consider a square n by n grid graph that looks like this. It is important to notice that this graph is 11 by 11. At any given point a man stands at an intersection and he only ever moves ...
678 views

### Growing Manhattan Ameobas

An ameoba graph* is a type of tree whose nodes all have values from 0 to some non-negative integer N, and any particular node with value x < N connects to x+1 distinct nodes with values x+1. ...
894 views

### Family Tree Solver

This is one of several challenges left for the community by Calvin's Hobbies. Take a "family tree describing" file with lines of the form: [ID] [mother ID] [father ID] [gender] [full name] such as ...
531 views

### How strong are nonary numbers?

You are given a nonary (base 9) non-negative integer consisting of the digits 0 through 8 as usual. However the number of digits in this number (with no leading zeros) is a prefect square. Because of ...
321 views

### Swing Through Trees with Your Grappling Hook

You have found the path through the forest and now plan on travelling along it. However, just before you start on your journey, the ground turns into lava. You manage to scurry up the nearest tree ...
1k views

### Extreme Whitewater Canoeing

You are paddling a canoe down a fairly fast whitewater river. Suddenly, your paddles explode, and you find yourself in a dangerous situation hurtling down a river rapid without any paddles. Luckily, ...
703 views

### Horror Movie Search Party

Plot: Jimmy is missing; we have to find him. We should split up. Plot twist: Jimmy is already dead. But, our cast doesn't know that, so they need to search the whole area anyway. There is an N ...
511 views

### Racketeer Taxi Driver

The Scenario You are a taxi driver in your city. You picked up a passenger from the airport and he told you the place he'd like to go. To earn more money, you need to drive as much as you can. ...
3k views

### To Vectory! â€“ The Vector Racing Grand Prix

User CarpetPython posted a new take on this problem which puts a much bigger focus on heuristic solutions, due to an increased search space. I personally think that challenge is much nicer than ...
2k views

### Are you in the biggest room?

Introduction You have recently accepted a job offer at a Pretty Good Software Company. You're pretty content with the size of your office, but do you have the biggest office? Its kinda hard to tell ...
2k views

### Mastermind strategy

I could only find code-golf challenges for Mastermind, so here's a code-challenge version that I would have liked to take on myself. An optimal strategy for the normal Mastermind game, MM(4,6), was ...
411 views

### Count the terminal cycles of a directed graph

Task You must write a program or function in the language of your choice which accurately counts the number of terminal cycles of a simple directed graph. This particular kind of directed graph is ...
860 views

### Find all reachable nodes in a graph

You are given a directed graph in an adjacency dictionary format. This can be whatever format is most natural for your language. For instance, in python, this would be a dictionary with keys of nodes ...
1k views

### Calculate your stack exchange reputation

Background: I often find that, when browsing a Stackexchange site, I begin to wonder how people get the amount of reputation that they have. I know I can always count on codegolf SE to solve my ...
341 views

### Wireless Keyboard Inteference

Initech are setting up an office of 36 employees in a soul-crushingly efficient square of cubicles, 6 desks long and 6 desks deep. Management has bought wireless keyboards in bulk from a cheap, ...
721 views

### Alex the Truck Driver

Alex is a Truck Driver who wants to find the quickest way to deliver goods to multiple cities. He knows the distances between his destinations, but you need to write a program to help him find the ...
357 views

### Determine number of unconnected components

You are given a graph represented through an adjacency list. For example, the input 1-2 2-3 3-4 4-1 would correspond to the graph with nodes 1, 2, 3 and 4, where 1 is connected to 2, 2 is connected ...
2k views

### Score a game of Go

Scoring a Go game is a task that is not all too easy. In the past there have been several debates about how to design rules to cover all the strange corner cases that may occur. Luckily, in this task ...
1k views

### City names game

If you like, write a program which sorts cities according to the rules of city name game. Each name of the city should start from the last letter in the previous city name. E.g. Lviv -> v -> ...
998 views

### Calculate Network Average Clustering Coefficient

The clustering coefficient of a graph (or network) is a: measure of degree to which nodes in a graph tend to cluster together The Wikipedia article gives a much better description of how ...
575 views

### Shortest route through a one-way system

My home town, Rhyl, has a one-way traffic system which seems to have been designed to keep people away from their destination for as long as possible. Your task, should you choose to attempt it, is to ...