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)

Solution pages

Hey there. I see you've been creating separate pages for the long output from Mathprog programs. That's good, but I want to suggest creating pages with titles like Task name/Language name to make sure people using every language can get a separate page if they need it. A page like KnapU sol should go at Knapsack problem/Unbounded/Mathprog instead. An added benefit of doing that is that it automatically adds a link back to the task at the top of the output page. Thanks for your solutions so far. It's nice to get new languages here. --Mwn3d 14:20, 10 January 2012 (UTC)

Signatures

To sign your posts, use --~~~~. You've signed a few using [[User:Dkf|Nigel Galloway]], which actually links over to Donal Fellow's user page. --Michael Mol 22:49, 13 January 2012 (UTC)

Math on RC

Did you know that we can use pieces of text like “<math>a_1 + b^2</math>” (with TeX/LaTeX formatted code inside) to create stuff that renders as:

This lets you avoid having to fiddle around with uploading pictures. (Mediawiki's configured to convert simple math to UNICODE for rendering, and complex stuff gets run through (La)TeX.) It's pretty awesome to use this for things like Continued fractions… –Donal Fellows 21:28, 27 February 2012 (UTC)

Minor tweaks to Ruby Semordnilap

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

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