Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,143,601 members, 7,781,908 topics. Date: Saturday, 30 March 2024 at 04:08 AM

Can You Solve GCHQ Xmas Puzzle? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Can You Solve GCHQ Xmas Puzzle? (3029 Views)

Can You Solve PHP Problems? Let's Find Out.. / Can You Solve This Tricky Question? / Number Generator Challenge : Can You Solve This? (2) (3) (4)

(1) (2) (Reply) (Go Down)

Can You Solve GCHQ Xmas Puzzle? by sinequanon: 5:58pm On Jan 14, 2016
Did anyone attempt this?

[img]http://www.i-programmer.info/images/stories/News/2015/Dec/B/gchqxmaspuzzle.jpg[/img]

http://www.i-programmer.info/news/204-challenges/9288-can-you-solve-gchqs-xmas-puzzle.html

The basic idea is that you have a 2D grid and along the rows and columns are lists of numbers that give how many runs of each length there are in the row and column. For example a row with 2, 4, 5 next to it would have three runs consisting of a run of 2, a run of 4 and a run of 5 black cells. Obviously a single row or column doesn't specify where the runs are but if you are given the information for all of the rows and columns you can see that a unique solution which satisfies all of the constraints might exist. If a unique solution doesn't exist then you can fix which one you want by providing some of the starting values.

1 Like 1 Share

Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 6:43pm On Jan 14, 2016
It is a very good programming exercise for anyone who already knows a programming language.

The first skill, here, involves the ability to convert a task which has been presented for easy interpretation by humans, into a process of functional steps that can be made easy for a computer.

This ability to create a technical specification is key to programming in the real world.
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 6:47pm On Jan 14, 2016
turn the numbers as if you are covering a carton .
blah! bah!
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 6:52pm On Jan 14, 2016
proxy20:
turn the numbers as if you are covering a carton .

blah! bah!

ok.. do it, and post your program..
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 9:01pm On Jan 15, 2016
^^

How far have you got?
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 9:09pm On Jan 15, 2016
I can't solve abstract cryptography .
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 9:16pm On Jan 15, 2016
proxy20:
I can't solve abstract cryptography .

Was your earlier post tongue in cheek?
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 9:20pm On Jan 15, 2016
// Don't mind me

bool CheckLine(Grid<char> & board, char mark, int row, int col, int dRow, int dCol) { for (int i = 0; i < 3; i++) { if (board[row][col] != mark) return false; row += dRow; col += dCol; } return true;
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 9:28pm On Jan 15, 2016
proxy20:
// Don't mind me

bool CheckLine(Grid<char> & board, char mark, int row, int col, int dRow, int dCol) { for (int i = 0; i < 3; i++) { if (board[row][col] != mark) return false; row += dRow; col += dCol; } return true;

Can you program at all?
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 9:53pm On Jan 15, 2016
sinequanon:


Can you program at all?
A little
Re: Can You Solve GCHQ Xmas Puzzle? by DonSegmond(m): 10:32pm On Jan 15, 2016
what do they mean by a "run of 2"
Re: Can You Solve GCHQ Xmas Puzzle? by DonSegmond(m): 10:56pm On Jan 15, 2016
solved it.
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 11:22pm On Jan 15, 2016
DonSegmond:
solved it.

That was quick..

Where's the answer? Did you google it? grin
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 2:21pm On Jan 16, 2016
/* This is a partial abstract program by proxy20 to solve the abstract programming in c++ . You are free to modify the codes */

#include <iostream>
Using namespace std;
int main ( )
{
array [] ={0,1,2,3,4,5,6,7,8,9,10} ;

// put many if statement for each of the elements
CheckLine(Grid<char> & board, char mark,
int row, int col, int dRow, int dCol) // what is the freaking answer !

if (CheckLine(board, mark, 7, 3, 1, 1,7)) return true; if (CheckLine(board, mark, 1, 1, 2, 2,1,1)) return true;
}
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 2:31pm On Jan 16, 2016
proxy20:
/* This is a partial abstract program by proxy20 to solve the abstract programming in c++ . You are free to modify the codes */

#include <iostream>
Using namespace std;
int main ( )
{
array [] ={0,1,2,3,4,5,6,7,8,9,10} ;

// put many if statement for each of the elements
CheckLine(Grid<char> & board, char mark,
int row, int col, int dRow, int dCol) // what is the freaking answer !

if (CheckLine(board, mark, 7, 3, 1, 1,7)) return true; if (CheckLine(board, mark, 1, 1, 2, 2,1,1)) return true;
}

So, you intend to generate all unconstrained configurations of the board and "check" for the one that conforms to the constraint criteria?
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 2:44pm On Jan 16, 2016
stack must be subjected that the restricted values must be removed in the configuration .
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 3:05pm On Jan 16, 2016
proxy20:
stack must be subjected that the restricted values must be removed in the configuration .

Which configuration? There are many. And how will you do it?
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 3:13pm On Jan 16, 2016
using abstract data class like grid or stack class .
You just have to manipulate some variable .
or using vector class

#include "vector.h"
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 3:15pm On Jan 16, 2016
proxy20:
using abstract data class like grid or stack class .
You just have to manipulate some variable .

You can't program with vague ideas like that.
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 3:22pm On Jan 16, 2016
One of the simplest classes in the ADT library is the Stack class, which is used to model a data structure called a stack, which turns out to be particularly useful in a variety of programming applications. A stack provides storage for a collection of data values, subject to the restriction that values must be removed from a stack in the opposite order from which they were added, so that the last item added to a stack is always the first item that gets removed.
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 3:33pm On Jan 16, 2016
proxy20:
One of the simplest classes in the ADT library is the Stack class, which is used to model a data structure called a stack, which turns out to be particularly useful in a variety of programming applications. A stack provides storage for a collection of data values, subject to the restriction that values must be removed from a stack in the opposite order from which they were added, so that the last item added to a stack is always the first item that gets removed.

I didn't say that a stack is a vague idea. It is a fundamental principle in programming.

I said that your understanding of how to use a stack for this problem appears to be vague.

Again, I ask you:

Which of the many configurations will you be putting on your "stack"? And how will you find them?

A vague answer that you will use some standard class is not enough.
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 3:52pm On Jan 16, 2016
From the herculean task . The basic idea is that you have a 2D grid andalong the rows and columns are lists of numbersthat give how many runs of each length there are in the row and column.

For (i=0;i>array.length; i++);
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 3:55pm On Jan 16, 2016
Have you tried using a bar code scanner to see if there are hidden clues .
Re: Can You Solve GCHQ Xmas Puzzle? by DonSegmond(m): 4:02pm On Jan 16, 2016
sinequanon:


That was quick..

Where's the answer? Did you google it? grin
No, it's a very simple problem to solve. I haven't seen anyone here heading towards the right direction.
But it's the same way you would solve a sudoku, or kenken puzzle. If you look at the puzzle, you can see that you have constraints, and even better yet, there is only one solution. Trying to brute force the puzzle will be foolish, so use a CLP solver. I used prolog's clpfd solver.
http://www.swi-prolog.org/man/clpfd.html

P/S, i didn't bother solving that actual puzzle. I just did a test for a 5x5 puzzle and know I can extend it to the big puzzle.
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 4:04pm On Jan 16, 2016
I can see the spatial arrangements of the numbers and black dot . It may mean something . Take a closer look at it in 3d .
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 4:06pm On Jan 16, 2016
cool
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 4:07pm On Jan 16, 2016
cool watching in 3d
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 4:10pm On Jan 16, 2016
DonSegmond:

No, it's a very simple problem to solve. I haven't seen anyone here heading towards the right direction.
But it's the same way you would solve a sudoku, or kenken puzzle. If you look at the puzzle, you can see that you have constraints, and even better yet, there is only one solution. Trying to brute force the puzzle will be foolish, so use a CLP solver. I used prolog's clpfd solver.
http://www.swi-prolog.org/man/clpfd.html
exactly
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 4:11pm On Jan 16, 2016
DonSegmond:

No, it's a very simple problem to solve. I haven't seen anyone here heading towards the right direction.
But it's the same way you would solve a sudoku, or kenken puzzle. If you look at the puzzle, you can see that you have constraints, and even better yet, there is only one solution. Trying to brute force the puzzle will be foolish, so use a CLP solver. I used prolog's clpfd solver.
http://www.swi-prolog.org/man/clpfd.html

That is the google answer, and it's a bit of a cheat because you don't write the solver yourself.

Don't worry. I have written my own full solution in HTML/Javascript (I used HTML/Javascript for accessibility).

I don't brute force anything, and it solves it in 20 milliseconds.

How long does your program take?
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 4:16pm On Jan 16, 2016
hope the results would be announced on bbc
Re: Can You Solve GCHQ Xmas Puzzle? by DonSegmond(m): 4:18pm On Jan 16, 2016
sinequanon:


That is the google answer, and it's a bit of a cheat because you don't write the solver yourself.

Don't worry. I have written my own full solution in HTML/Javascript (I used HTML/Javascript for accessibility).

I don't brute force anything, and it solves it in 20 milliseconds.

How long does your program take?

Google answer? You are stupid. Using a constraint solver is a cheat? SMDH. Right, your javascript solution solves in 20 milliseconds? lol, right, well that's a cheat, because you didn't write the javascript interpreter yourself.
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 4:35pm On Jan 16, 2016
DonSegmond:


Google answer? You are stupid. Using a constraint solver is a cheat? SMDH. Right, your javascript solution solves in 20 milliseconds? lol, right, well that's a cheat, because you didn't write the javascript interpreter yourself.

Don't be foolish.

The Javascript interpreter does not contain the methodology for solving the problem.

The method you have quoted, easily available with a quick google search, only restates the problem to make amenable to a solver which you didn't write. I hope that you are not too foolish to know the difference between a solver and an interpreter? grin

I note that you kept quiet about how quickly your supposed program solves the problem.

(1) (2) (Reply)

Kivy Vs Android Studio Which Is The Best For Android App Development? / C++ Helpline / Videos Tutorial / Ebooks

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 34
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.