Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,339 members, 7,811,983 topics. Date: Monday, 29 April 2024 at 04:36 AM

Can You Solve GCHQ Xmas Puzzle? - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / Can You Solve GCHQ Xmas Puzzle? (3049 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)

Re: Can You Solve GCHQ Xmas Puzzle? by DonSegmond(m): 4:57pm On Jan 16, 2016
sinequanon:


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.
Nah, you are the one being silly. The puzzle asked for the solution, didn't ask for the method. You would be a fool to code up a constraint solver when there is already one. Just like you would be a fool to write your own quicksort function when pretty much all language already provide one.

With that said, a constraint solver doesn't automatically solve any problem. You still have to write the code as I did.

If you care about the time, my solution finds all 4 possible solutions in 0.242 seconds.
% 2,906,715 inferences, 0.238 CPU in 0.238 seconds (100% CPU, 12228088 Lips)
% 5,188 inferences, 0.001 CPU in 0.001 seconds (92% CPU, 9490707 Lips)
% 6,455 inferences, 0.001 CPU in 0.002 seconds (92% CPU, 4314254 Lips)
% 5,189 inferences, 0.001 CPU in 0.001 seconds (92% CPU, 7862050 Lips)

And note, my goal was not to be performant but for a small and concise amount of code, if I care about speed, I would implement it in C++.

My solution comes out to 33 lines of code. Don't be a troll, you should learn you some prolog or eclipse.
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 5:17pm On Jan 16, 2016
DonSegmond:

Nah, you are the one being silly. The puzzle asked for the solution, didn't ask for the method. You would be a fool to code up a constraint solver when there is already one. Just like you would be a fool to write your own quicksort function when pretty much all language already provide one.

With that said, a constraint solver doesn't automatically solve any problem. You still have to write the code as I did.

If you care about the time, my solution finds all 4 possible solutions in 0.242 seconds.
% 2,906,715 inferences, 0.238 CPU in 0.238 seconds (100% CPU, 12228088 Lips)
% 5,188 inferences, 0.001 CPU in 0.001 seconds (92% CPU, 9490707 Lips)
% 6,455 inferences, 0.001 CPU in 0.002 seconds (92% CPU, 4314254 Lips)
% 5,189 inferences, 0.001 CPU in 0.001 seconds (92% CPU, 7862050 Lips)

And note, my goal was not to be performant but for a small and concise amount of code, if I care about speed, I would implement it in C++.

My solution comes out to 33 lines of code. Don't be a troll, you should learn you some prolog or eclipse.

You are the one who started trolling by getting personal. Don't add hypocrisy to that.

There is only one solution.

Clearly, GCHQ are not looking for the solution. LOL!! They know the solution.

They want to recruit folk with ingenuity, not folk who can google up a constraint solver and pretend that knowledge of prolog or eclipse has anything to do with anything.

And, in any case, what I am interested in is folk with the ability to solve the problem, not just to call a solver.
Re: Can You Solve GCHQ Xmas Puzzle? by Nobody: 9:11pm On Jan 16, 2016
.
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 9:31pm On Jan 16, 2016


This is the output from my HTML/Javascript program.

As well as solve the original problem, you can do a lot of other related things.
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 12:36pm On Jan 18, 2016
DonSegmond:

Nah, you are the one being silly. The puzzle asked for the solution, didn't ask for the method. You would be a fool to code up a constraint solver when there is already one. Just like you would be a fool to write your own quicksort function when pretty much all language already provide one.

With that said, a constraint solver doesn't automatically solve any problem. You still have to write the code as I did.

If you care about the time, my solution finds all 4 possible solutions in 0.242 seconds.
% 2,906,715 inferences, 0.238 CPU in 0.238 seconds (100% CPU, 12228088 Lips)
% 5,188 inferences, 0.001 CPU in 0.001 seconds (92% CPU, 9490707 Lips)
% 6,455 inferences, 0.001 CPU in 0.002 seconds (92% CPU, 4314254 Lips)
% 5,189 inferences, 0.001 CPU in 0.001 seconds (92% CPU, 7862050 Lips)

And note, my goal was not to be performant but for a small and concise amount of code, if I care about speed, I would implement it in C++.

My solution comes out to 33 lines of code. Don't be a troll, you should learn you some prolog or eclipse.

So, where have you disappeared to.

I don't believe you wrote any code. I think that you have just cut and pasted those results from somewhere.

And the person you copied it from didn't write "the" code. "The code" is in the solver, and he just presented the data to it.

There is only one solution, but you claim that there are four, so it seems as if you didn't understand what you cut and pasted.

My program, which runs in a browser, which uses an interpreter, is 10 times faster than your compiled program!!! < 20 milliseconds cf your 200+ milliseconds.

Compiled programs are supposed to be much faster than interpreted programs, so the solution you have presented appears to be very inefficient.


Re-writing your calling program in C++ won't change the times shown. LOL!!! They are fixed by the speed of the solver.


And I think that it is fair to say that the main reason you call a solver is because you don't know how to write one, and you are kidding yourself that it is about reusability.
Re: Can You Solve GCHQ Xmas Puzzle? by DonSegmond(m): 12:30am On Jan 19, 2016
sinequanon:


So, where have you disappeared to.

I don't believe you wrote any code. I think that you have just cut and pasted those results from somewhere.

And the person you copied it from didn't write "the" code. "The code" is in the solver, and he just presented the data to it.

There is only one solution, but you claim that there are four, so it seems as if you didn't understand what you cut and pasted.

My program, which runs in a browser, which uses an interpreter, is 10 times faster than your compiled program!!! < 20 milliseconds cf your 200+ milliseconds.

Compiled programs are supposed to be much faster than interpreted programs, so the solution you have presented appears to be very inefficient.


Re-writing your calling program in C++ won't change the times shown. LOL!!! They are fixed by the speed of the solver.


And I think that it is fair to say that the main reason you call a solver is because you don't know how to write one, and you are kidding yourself that it is about reusability.
Prolog is an interpreted language, your lack of knowing this and not even looking into this shows how much of a troll you are. There are 4 solutions. Anyways, you win, you are the smartest and greatest. Later


?- solve_puzzle.
[[1,1,1,1,1,1,1,0,1,1,1,0,0,0,1,0,1,0,1,1,1,1,1,1,1],[1,0,0,0,0,0,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,0,1],[1,0,1,1,1,0,1,0,0,0,0,0,1,1,1,0,1,0,1,0,1,1,1,0,1],[1,0,1,1,1,0,1,0,1,0,0,1,1,1,1,1,1,0,1,0,1,1,1,0,1],[1,0,1,1,1,0,1,0,0,1,1,1,1,1,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,0,1,1,0,0,0,0,1,0,0,0,1,0],[0,1,1,1,1,0,1,0,1,1,1,1,0,1,1,0,1,0,0,0,0,1,1,0,0],[0,1,0,1,0,0,0,1,0,0,0,1,0,1,0,1,1,1,1,0,1,0,1,1,1],[0,0,1,1,0,0,1,0,1,0,1,0,0,0,0,0,0,1,1,0,1,1,1,1,1],[0,0,0,1,1,1,0,1,1,0,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1],[1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,1,1,0,0,0,0,1,0],[0,1,1,0,1,0,0,1,1,0,0,1,1,0,0,1,1,1,0,0,0,0,0,1,0],[1,1,1,0,1,0,1,0,1,0,0,0,0,1,0,0,1,1,1,1,1,0,1,0,0],[0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,1,1,0,0,0,1,1,1,1,1],[1,1,1,1,1,1,1,0,1,0,0,0,1,1,0,0,1,0,1,0,1,0,1,1,1],[1,0,0,0,0,0,1,0,1,1,0,0,1,0,0,1,1,0,0,0,1,1,0,1,0],[1,0,1,1,1,0,1,0,0,0,1,1,1,1,0,0,1,1,1,1,1,0,0,1,0],[1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1],[1,0,1,1,1,0,1,0,1,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],[1,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0,0,1,0,1,0,1,1,0,0],[1,1,1,1,1,1,1,0,1,1,0,0,0,1,0,1,1,0,0,0,1,1,1,1,1]]
true.
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 1:01am On Jan 19, 2016
DonSegmond:

Prolog is an interpreted language, your lack of knowing this and not even looking into this shows how much of a troll you are. There are 4 solutions. Anyways, you win, you are the smartest and greatest. Later.

There are plenty of prolog compilers.

https://en.wikipedia.org/wiki/Comparison_of_Prolog_implementations

DonSegmond:
[1,0,1,1,0,1,1,1,0,0,1,0,1,0,1,1,1,0, [size=18pt]0[/size] ,1,0,1,0,1,1]

(9th array of 1st *cough* "solution".... LOL!!!)

Where does this come from, troll?

The highlighted cell is even GIVEN as black. You don't even have to calculate it. LOL! LOL! LOL!!!!

Next time you cut and paste, try to understand what you crib off google first.

DonSegmond:
[1,1,1,0,1,0,1,0,1,0,0, [size=18pt]0[/size] ,0,1,0,0,1,1,1,1,1,0,1,0,0]

17th array of 2nd and 4th "solutions" WRONG!
Re: Can You Solve GCHQ Xmas Puzzle? by DonSegmond(m): 3:20am On Jan 19, 2016
sinequanon:


There are plenty of prolog compilers.

https://en.wikipedia.org/wiki/Comparison_of_Prolog_implementations



(9th array of 1st *cough* "solution".... LOL!!!)

Where does this come from, troll?

The highlighted cell is even GIVEN as black. You don't even have to calculate it. LOL! LOL! LOL!!!!

Next time you cut and paste, try to understand what you crib off google first.



17th array of 2nd and 4th "solutions" WRONG!


if you knew anything about how prolog worked, you would know that it's not really compile as in native code. it's in the same class as lua and python with bytecode interpreter. you can bundle the bytecode and interpreter into one big binary blob but that doesn't make it compiled. unlike lua-jit and the jvm, the research on prolog is not deep and the most efficient environment was invented in the 1980's, the warren abstract machine. anyway, i'm done with this discussion.
Re: Can You Solve GCHQ Xmas Puzzle? by sinequanon: 12:16pm On Jan 19, 2016
DonSegmond:

if you knew anything about how prolog worked, you would know that it's [size=18pt]not really compile as in native code[/size]. it's in the same class as lua and python with bytecode interpreter. you can bundle the bytecode and interpreter into one big binary blob but that doesn't make it compiled. unlike lua-jit and the jvm, the research on prolog is not deep and the most efficient environment was invented in the 1980's, the warren abstract machine. anyway, i'm done with this discussion.

WRONG! You can do either.

[url]http://pauillac.inria.fr/~haemmerl/gprolog-rh/doc/manual008.html[/url]

A Prolog program [size=18pt]can be compiled to native code[/size] to give rise to a machine-dependent executable using the GNU Prolog compiler. However native-code predicates cannot be listed nor fully debugged. So there is an alternative to native-code compilation: byte-code compilation.

How can you claim to be a prolog programmer but not know this?

Well, I can see why you are "done with this discussion". You are posting too much humbug, and getting caught out.

Do you STILL think there are 4 solutions, or is it back to google to find out what the programmers you copied from were talking about?

(1) (2) (Reply)

Hotel Booking And Reservation Assignment For A 200level Student (c++). / Collaborators Wanted For This Online Voting Application / 12 Year-old Nigerian Bags Sun's Java Certificate

(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. 112
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.