| Eludias | An approach for large array would be more like: |
| kesV | best you can do is just use a counting sort. that would be O(n) |
| Eludias | counter = Hash.new(0); arr.each { |i| counter[i] += 1 }; arr.find_all { |i| i > 1 } ..which is indeed O(n). [...but has nothing to do with sort] |
| Silowyi | Eludias thanks, I for some reason didn't think about that. |
| kesV | Eludias: a counting sort is not a real sort it's pretty much exactly what you gave there ;) |
| Eludias | kesV: O. Ok then :) |
| Silowyi | technically a counting sort would be counter = Array.new; arr.each { |i| counter[i] += 1 }; etc... but that's being purist :P |
| kesV | well, if you only have integers |
| Silowyi | true |
| kesV | with more complex objects you need a map. and obviously counting sort only works if we know we are dealing with a restricted range of objects |
| bobwhoops | so I'm still stuck on how to use module PTY. I can read stuff from a curses program with reader.read(n), but I'd like to be able to read all the input available at once. Can someone just point me in the right direction? |
| technomancy | does this evaluate to Feb 28 for anyone else? Date.parse('March 1 2007').to_time i've confirmed it on two 64-bit machines, and it works fine on the two 32-bit machines i've tried anyone? |
| Eludias | technomancy: Returns 1 march here (32 bits). |
| technomancy | interesting |
| j2m | Am I alive? |
| Eludias | bobwhoops: Probably use select() and sysread()... |
| bobwhoops | Eludias: thanks |
| jontec | I need some help... I have a string, a regular html tag... I'm trying to match it with regex so that I can delete it... with the string "<a href=\"\"", why doesn't /<.>/ match it? /<./ does |
| Eludias | bobwhoops: while true; select([io]); buffer = io.sysread(1500); break if !buffer; end |
| bobwhoops | jontec: /<.*>/ |
| jontec | bobwhoops: oh! I didn't realize that I needed a quantifier, thanks. :D |
| ehird | if i do x = NEW OBJECT HERE y = x does y take up the whole memory space of x or is it just a small reference? |
| Eludias | ehird: Same as Java. Small reference. |
| ehird | just because i'm in #java doesn't mean i come from java thank you :( |
| Eludias | ehird: Ok, you're going to #java then :) ? |
| ehird | no, i'm taking a look at java while sticking with ruby for most things :P |
| Eludias | ehird: (exceptions: Fixnums. Those are copied and take up the whole memory space of x. But you won't notice.) |
| gnufied | Eridius, will this work: arr.find_all { |i| i.count > 1 } ? where arr would be the array? |
| Eludias | gnufied: That will return an array containg double-values, yes. |