User talk:Nigel Galloway

From Rosetta Code

In re Execute Ramsey Mathprog; what were you trying to achieve with that? What language were you writing in? –Donal Fellows 13:16, 5 January 2012 (UTC)

Minor tweaks to Ruby Semordnilap[edit]

I found your approach to the solution refreshingly different from the others on the page. Very nice. I have a few notes on the Ruby specifics that you may find useful:

  • Ruby has String#chomp built-in, so there's no need to reimplement it with a manual tr.
  • Blocks of the form { |obj| obj.method } can be shortened to parameters of the form &:method.
  • String#== has the same semantics as String#eql? and seems to be preferred by the community in idiomatic Ruby.
  • Instead of initializing an array to empty and then pushing onto it conditionally inside a loop, you can construct the new array as a piece by using select instead of each.

Applying those to your code, you get this:

   DICT=File.readlines("unixdict.txt").collect(&:chomp)
   i = 0
   res = DICT.collect(&:reverse).sort.select { |z|
     i+=1 while z > DICT[i] and i < DICT.length-1
     z == DICT[i] and z < z.reverse
   }

Hope you find the above useful or at least interesting. --Markjreed (talk) 10:20, 15 May 2013 (UTC)

Thanks for the interest. The manual tr was put in by Paddy3118 so I take no credit for it and I am more than happy to make the change. Spoon! then changed it to use a set in immitation of the Python. I wasn't happy about that!, walking sorted files seemed good to me. C has since implemented that to perfection. The each seems more natural to me, in the real world I would probably want to write these pairs to a file or something, but for the purpose of this example why not?--Nigel Galloway (talk) 12:09, 17 May 2013 (UTC)

Abandoned Task: Blackjack strategy[edit]

Hi Nigel, you might revive it by adding its first implementation...
--Paddy3118 (talk) 11:24, 12 November 2014 (UTC)

Discussions on your new task Textonyms[edit]

Hi Nigel, I wondered if you could join in the discussions at Talk:Textonyms thanks. --Paddy3118 (talk) 07:46, 6 February 2015 (UTC)

I noted that you are changing the wordlist of an established task with 15 solutions already. Would this invalidate the existing examples and if so, for what reason? THanks. --Paddy3118 (talk) 13:02, 6 May 2015 (UTC)


Inflammatory stuff[edit]

Nigel, it's a great analysis, but technically adding an answer based on this is excluded from the task as I did not want people to just copy an analytical solution from somewhere (OEIS has one) and use that. What to do? Right now I've added a note to your example on the page to discourage others from going down the same route but left it in place. A workable compromise? --Paddy3118 (talk) 06:19, 12 May 2015 (UTC)
Well Paddy3118 you certainly seem to like these silly notes, certainly you are not a mathematician or a lawyer, so this should be interesting. According to the task description I should calculate the starting value. By what stretch of the English language do any of the solutions calculate the starting value?
Let us compare my solution with the Python solution. On numerous combinatronics problems I have stressed the importance of separating the verification of candidates from the selection of candidates. In spite of this and whatever the drivel "Parameterised the number of sailors using an inner loop including the last mornings case" means the Python solution does not do this, and for that alone is worth no more than 0 out of 100.
I contend that my solution does meet the task requirements because _ng verifies each candidate by applying the problems constrains using integer divisions and remainders and tests on remainders, any lawyer want to tell me otherwise?.
The question is how do I select the candidates? To answer this I introduce the oxymoron 'honest sailors' as a literary device to add dramatic effect and a technical device to explain the selection.
The case when 4 sailors are honest and one dishonest is constructed as the initial basis:
26 5
20 4
It is impossible to have 2 dishonest sailors unless at least 1 sailor is dishonest. So I suggest the case for 2 dishonest sailors is a proper subset of the set of solutions for 1 dishonest sailor which I shall represent as 20+g*20. I try each of these values against my verification procedure which returns false until g=2 giving the answer:
96 19
76 15
60 12
It is impossible to have 3 dishonest sailors unless at least 2 sailors are dishonest. So I suggest the case for 3 dishonest sailors is a proper subset of the set of solutions for 2 dishonest sailors which I shall represent as 60+g*80. I try each of these values against my verification procedure which returns true with g=0 giving the answer:
121 24
 96 19
 76 15
 60 12
It is impossible to have 4 dishonest sailors unless at least 3 sailors are dishonest. So I suggest the case for 4 dishonest sailors is a proper subset of the set of solutions for 3 dishonest sailors which I shall represent as 60+g*320. I try each of these values against my verification procedure which returns false until g=3 giving the answer:
2496 499
1996 399
1596 319
1276 255
1020 204
It is impossible to have 5 dishonest sailors unless at least 4 sailors are dishonest. So I suggest the case for 5 dishonest sailors is a proper subset of the set of solutions for 4 dishonest sailors which I shall represent as 1020+g*1280. I try each of these values against my verification procedure which returns true with g=0 giving the answer:
3121 624
2496 499
1996 399
1596 319
1276 255
1020 204
So in spite of stopping and starting I find the solution with 8 candidates. Which is certainly more calculated than the Python candidate selection which would better be described as brainless. As with all good AI programs on classical computers it is possible to ask the program to explain its reasoning, the output for the 100 case is Sailors, coconuts and a monkey problem/Ruby output 100 honest sailors. As you can see it selects 4950 candidates to find the solution for 100 sailors, less than the Python solution uses for 5 sailors.
Compromise? You must decide what calculate means. If it means calculate, then you should specify the equation you want to use to calculate the correct value in steps 1 and 3 which must simply be verified in steps 2 and 4. You should then stick a silly note on just about every solution. If it is acceptable to provide candidates to the verification procedure until a correct solution is found, then I see no reason to consider my solution less worthy than any other (actually I think it's better than any other) and you should remove your silly note from my solution.

--Nigel Galloway (talk) 14:35, 13 May 2015 (UTC)