Closed schmich closed 7 years ago
Sources: Amazon, BGG, and my own copy.
In Quiddler, the letters on the card determine the value (e.g. every "A" is worth 2 points), but I included the point values anyway.
require 'json' cards = %w( o2 a2 a2 a2 cl10 t3 y4 a2 a2 r5 o2 g6 n5 t3 o2 i2 k8 s3 a2 i2 e2 r5 d5 l3 i2 g6 y4 d5 e2 u4 g6 u4 i2 b8 u4 t3 cl10 t3 u4 th9 v11 s3 k8 x12 th9 l3 e2 o2 n5 t3 a2 g6 i2 n5 m5 l3 r5 a2 c8 a2 qu9 e2 y4 p6 er7 i2 e2 e2 t3 w10 in7 f6 n5 u4 r5 e2 n5 f6 r5 w10 e2 o2 h7 qu9 z14 q15 a2 e2 j13 e2 d5 q15 h7 s3 b8 z14 u4 o2 l3 e2 d5 i2 i2 r5 o2 y4 m5 e2 s3 j13 p6 in7 c8 er7 o2 v11 x12 n5 ) raise 'Invalid data.' if cards.count != 118 groups = {} lvmap = {} cards.each do |c| m = c.match(/([a-z]+)(\d+)/) letters, value = m[1], m[2].to_i raise 'Invalid data.' if !lvmap[letters].nil? && lvmap[letters] != value lvmap[letters] = value groups[c] ||= { letters: letters, value: value, count: 0 } groups[c][:count] += 1 end raise 'Invalid data.' if groups.map { |_, g| g[:count] }.inject(0, :+) != 118 puts JSON.pretty_generate(groups.values.sort_by { |g| g[:letters] }, indent: ' ')
Another excellent contribution - Thank you! 😄 Merging.
Sources: Amazon, BGG, and my own copy.
In Quiddler, the letters on the card determine the value (e.g. every "A" is worth 2 points), but I included the point values anyway.