From: Josef 'Jupp' Schugt Date: 2006-10-20T07:07:09+09:00 Subject: Re: How to the output in 12x8 format -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Li Chen wrote: | I have an array containing 96 elements. I want to print the array | in 12x8 format. Any comments? Old school way (Beware! Ternary operator ahead!): a = (1..96).to_a.reverse a.each_with_index{|x,i|print x,i%12==11?"\n":"\t"} Idea: Iterate x over all elements of a . print x . is it value number eleven (the twelveth) in the row? . . if so break line . . if not jump to next tabulator . condition ends iteration ends Jupp -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFN/b0rhv7B2zGV08RAnGUAJ0YcmrBhwZzORu0zxzZ7ObuxV1YpwCg4GAk dc6aobYd2tKBxQzJ8Wq4Fpk= =k96z -----END PGP SIGNATURE-----