Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^2: Inputing vectors into a scrabble-esque game

by johngg (Canon)
on Nov 02, 2019 at 16:40 UTC ( #11108248=note: print w/replies, xml ) Need Help??

in reply to Re: Inputing vectors into a scrabble-esque game
in thread Inputing vectors into a scrabble-esque game

Perhaps you can save some fiddly typing map'ing the product of two source arrays to produce the @letters array. It doesn't look quite as straightforward but might be less prone to typos.

use 5.026; use warnings; my @letters = do { my @chars = ( q{a} .. q{z} ); my @counts = ( 9, 2, 2, 4, 12, 2, 4, 2, 9, 1, 1, 4, 2, 6, 8, 2, 1, 6, 4, 6, 4, 2, 2, 1, 2, 1 ); map { ( $chars[ $_ ] ) x $counts[ $_ ] } 0 .. 25; }; say join q{}, @letters;


aaaaaaaaabbccddddeeeeeeeeeeeeffgggghhiiiiiiiiijkllllmmnnnnnnoooooooopp +qrrrrrrssssttttttuuuuvvwwxyyz

I hope this is of interest.



Replies are listed 'Best First'.
Re^3: Inputing vectors into a scrabble-esque game
by GrandFather (Sage) on Nov 03, 2019 at 10:03 UTC

    But way less verifiable with a quick look. Keystrokes are much less important than understanding. The long winded suggestion I made is easy to understand even if you don't speak Perl and is easy to check. Anything that breaks the obvious one to one visual mapping between the letter and its repeat count is a step backwards for maintainability and easy understanding.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11108248]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2020-05-29 13:18 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (169 votes). Check out past polls.