Skip to main content
4 events
when toggle format what by license comment
Jul 22, 2017 at 14:21 comment added Eric Duminil deck.sort_by!{rand} is shorter.
Sep 5, 2014 at 19:36 comment added hobbs @JustinMorgan yes, 52 times it deletes a random card from deck and adds it to the internal list of results that map is accumulating. Then when there's nothing left in deck the map result gets copied into deck. Basically there's a temporary, but it's a language feature rather than an explicit variable :)
Apr 20, 2011 at 20:27 comment added Justin Morgan I wouldn't call it cheating, per se, but deck[0..51] does skirt the "no variables" rule somewhat by using a feature of the language. It's fair, I just think it loses some of the challenge. :) I don't know Ruby; can you explain the (0..51).map{deck.delete_at(rand deck.length)} part? Does that delete cards from deck?
Apr 19, 2011 at 17:48 history answered Matma Rex CC BY-SA 3.0