J
James Edward Gray II
And finally, here's to you, Mr. Ruby Quiz creator guy, for coming
up with a Ruby quiz that really peaked my interest![]()
Thank Ben Bleything. It was his idea.
James Edward Gray II
And finally, here's to you, Mr. Ruby Quiz creator guy, for coming
up with a Ruby quiz that really peaked my interest![]()
I also enjoyed the opportunity to explore sets and things; more RQs
that can involve the standard library would be awesome.
"Try transposing your matrix first, if that is what you need. Are you
dealing with transformation matrices (which are not real matrices) ?"
Yes indeed, SVG 2D transformation matrices. These matrices are 3x3.
Cameron said:"the included Matrix library in ruby is NOT FAST. There are other libs
that do this on the C level, such as NArray, that will allow much better
performance for some graphical uses."
T. W. Urp said:Vincent Fourmond wrote long time ago:
They never taught me about transposing, just matrix multiplication, and
googel didnt help either. What is transposing (for transformation matrices)?
T. W. Urp said:They never taught me about transposing, just matrix multiplication, and
googel didnt help either. What is transposing (for transformation matrices)?
T. W. Urp said:Vincent Fourmond wrote long time ago:
They never taught me about transposing, just matrix multiplication,
and googel didnt help either. What is transposing (for
transformation matrices)?
C:\>ri transpose
More than one method matched your request. You can refine
your search by asking for information on one of:
Array#transpose, Matrix#transpose
C:\>ri Array.transpose
C:\>ri Matrix.transpose
Ruby said:The three rules of Ruby Quiz:
1. Please do not post any solutions or spoiler discussion for this quiz until
48 hours have passed from the time on this message.
2. Support Ruby Quiz by submitting ideas as often as you can:
http://www.rubyquiz.com/
3. Enjoy!
Suggestion: A [QUIZ] in the subject of emails about the problem helps everyone
on Ruby Talk follow the discussion. Please reply to the original quiz message,
if you can.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
by Ben Bleything
This is a riff on the Jumble puzzle found in many (US) newspapers. More
specifically, it's based on the game TextTwist[1], made by GameHouse[2] and
published in various places around the web.
The mechanic of TextTwist is simple. The player is given six letters and is
tasked with unscrambling those letters into as many words as possible. If the
player can use all six letters in a word, they proceed to the next round.
Your task is to build the back-end engine to run a TextTwist clone. Effectively,
this means that you must generate a list of three- to six-letter words that can
all be constructed from the same six letters. This list must contain at least
one six-letter word.
Bonus points for building a completely functional game!
[1]: http://games.yahoo.com/games/texttwist.html (just one example, java)
[2]: http://www.gamehouse.com/
Given a matrix "a" with "m" rows and "n" columnsT. W. Urp said:Vincent Fourmond wrote long time ago:
They never taught me about transposing, just matrix multiplication, and
googel didnt help either. What is transposing (for transformation matrices)?
Yes!Thanks. While my simple graphic
genny isnt time-critical, and a SVG file might take 2-3 seconds to render,
I will look into NArray. Is NArray what you would recommend?
This just solves the find-all-subwords problem:
target = ARGV[0]
dict = ARGV[1] || 'sowpods'
reduced = target.split(//).sort.uniq.join
primes = [2, 3, 5, 7, 11, 13]
factors = []
reduced.split(//).each_with_index {|e, i|
factors[e[0]] = primes
}
target_num = 1
target.each_byte {|i| target_num *= factors}
IO.foreach(dict) {|word|
word.chomp!
next unless (word =~ /^[#{reduced}]+$/) &&
(word.length < 7) && (word.length > 2)
p = 1
word.each_byte {|i| p *= factors}
puts word if target_num % p == 0
}
That's neat, and is a good general way of checking for inclusion (so you can
extend it past characters in a string which might not have an .include?
method). You probably don't want that .uniq in there though as that excludes
you from matching 'hell' out of 'hello', for example.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.