greptilian logo

IRC log for #sourcefu, 2013-05-30

http://sourcefu.com

| Channels | #sourcefu index | Today | | Search | Google Search | Plain-Text | plain, newest first | summary

All times shown according to UTC.

Time S Nick Message
00:14 aditsu pdurbin: the clip doesn't say anything about supercomputing or parallelization, it just presents it as a $99 raspberry pi that runs ubuntu
00:15 aditsu (the first clip)
00:24 aditsu hmm 64 cores sound interesting though
00:31 aditsu lol "The answer is 42 !!!"
00:33 pdurbin oh, I didn't watch the clip
00:55 aditsu the other clips are different though
00:55 aditsu well, anyway, looking forward to general availability :)
01:58 pdurbin :)
02:03 codex any ruby people still here? :)
02:04 pdurbin agoddard: you're a ruby person
02:05 codex does ruby not have a scope?
02:06 codex translation: is everything in the same scope?
02:07 pdurbin I sure hope ruby has scope :)
02:08 codex pdurbin: http://pastebin.com/k7biLGvb
02:09 codex solving this: http://programmingpraxis.com -- MindCipher - #2 (1978)
02:10 codex figured it's a good way to learn ruby
02:10 codex :)
02:11 codex there is something quite elegant about it
02:14 pdurbin elegant about ruby?
02:14 codex yea
02:14 codex it feels minimalistic which is nice
02:14 codex and it seems to combine everything i like about perl and python
02:14 pdurbin I hear that a lot
02:16 codex http://pastebin.com/5i6JJr6f
02:16 codex ^ here's a cleaned up version. so the 'r' array seems to have the last # that many times
02:16 codex and i don't know why
02:30 pdurbin don't know why all the 9999's at the end?
02:34 agoddard heyooo!
02:35 codex agoddard: great timing!
02:35 codex pdurbin: exactly
02:35 agoddard before the end of the while block, throw a puts "r is now #{r}" and it'll give you a hint about what's join on
02:35 codex it's definitely a scope issue
02:35 agoddard s/join/goin
02:35 codex agoddard: i did, so noticing that it looks like a local var
02:35 codex but it's putting it that many times
02:35 codex (based on the loop)
02:35 codex so guessing local to IF
02:37 codex oh, scope is shared from if to local
02:37 codex well that's annoying
02:38 agoddard yep
02:38 codex it looks like if blocks do not introduce a scope?
02:38 codex is this new? I could've sworn in older versions of ruby they did
02:39 agoddard I think it is, post 1.9
02:39 codex so how do you get around it? :)
02:41 agoddard brb phone :(
02:41 agoddard actually.. "FactTime" 0_o
02:42 agoddard s/Fact/Face
02:49 pdurbin I'm definitely surprised by the "r is now #{r}" output just before the end of the while block
03:01 codex i can't believe this either. I am reading up on it and the two "excuses" are migrating to 2.0 and being able to use stuff declared in local if blocks
03:01 codex if you want to use it, don't declare it in an if block
03:01 codex but i guess this goes against the whole "don't use global vars" ruby mentality
03:02 agoddard back
03:04 agoddard that code is the same in ruby 2
03:04 agoddard lmao, just do this ;)         r.push("#{year}")
03:08 pdurbin agoddard: that works but it's weird
03:09 pdurbin I get that "#{year}" is a string
03:09 pdurbin dunno what r.push(year) is doing
03:13 agoddard the bit that's confusing me is that year is a string anyway
03:21 agoddard pretty sure the internet just stopped working #massiveThunderStorm
03:25 pdurbin heh
03:35 codex neighbor has a ham radio antenna like 50ft above his house
03:35 codex it was insane when a lightning bolt hit it
03:35 codex everything in our house shook and we are 2-3 houses away
03:36 codex agoddard: so explain why i need to do #{year}
03:36 codex pdurbin: it's a string so i can slice it
03:37 codex it made more sense since the "math" operation is only done after the pieces have been assembled
03:45 agoddard w00t it's back!
03:46 codex heh
03:47 codex so yea, is it that i am passing a reference by default?
03:47 codex and as the variable increases -- my passed ref. increases?
03:47 agoddard codex: the #{year} thing puzzles me, I assume it's 'cause another method, like next! isn't affecting it, but I don't know why, when they're both strings
03:48 agoddard right, when year increases, so does the thing you're putting in the array
03:50 codex i found sometging that might explain it
03:50 codex i think my assumption is correct
03:50 codex http://www.tutorialspoint.com/ruby/ruby_variables.htm
03:50 codex "You can substitute the value of any Ruby expression into a string using the sequence #{ expr }. Here expr could be any ruby expression."
03:50 codex it looks like #{ ... } puts the VALUE
03:50 codex so the other one must pass the object, and because it's not a local scope, the definition of that object in the IF block is later modified by the incrementor
03:52 agoddard nice, that makes sense
03:52 codex then again, 'year = year.next' makes it work the other way...so something is happening there
03:52 codex very weird
03:52 agoddard oh, then that means this would work ;) r.push("#{year}".to_i)
03:53 agoddard then, so would year.to_i
03:57 codex I am actually looking at shortening it now -- was able to cut it down by 30%...ruby is a sick language
04:00 agoddard sick as in sick or sick as in siq? :/
04:01 agoddard sick == siq ? sick : sick
04:01 agoddard alright I gotta bounce, little grizzly baby doesn't want to sleep
04:02 agoddard thanks for the fun, I learned something new! I should  hang out in sourcefu more :D
04:12 codex agoddard: sick as in i turned that 1-page code into this: http://pastebin.com/AVbnUZUG
04:12 codex pdurbin: ^
04:15 codex or to be even fancier:
04:15 codex r = []; 1978.upto(9999) { |y| y=y.to_s; (("#{y[0]}#{y[1]}".to_i +
04:15 codex "#{y[2]}#{y[3]}".to_i) == ("#{y[1]}#{y[2]}".to_i))?r.push(y):''; }; puts r.to_s
04:15 codex that's it :)
06:44 aditsu I'd like to bring up the 100 prisoners puzzle again
06:45 aditsu so far nobody solved it (from the people I told it to)
06:46 aditsu it's a pity, as the solution is so cool
09:52 pdurbin aditsu: I give up. just tell us :)
09:53 aditsu oh alright :) it's rather simple actually
09:54 aditsu we can assume each prisoner has a number from 1 to 100
09:55 aditsu and either each photo has the corresponding number on it, or the prisoners can memorize the number association
09:55 aditsu now each prisoner opens to box corresponding to his own number
09:55 aditsu e.g. prisoner with number 20 opens the 20th box
09:56 aditsu then if he finds a picture of prisoner number 53, he next opens the 53rd box
09:56 aditsu and so on, until he finds his own picture or fails after 50 boxes
09:56 aditsu this strategy is successful if the permutation of pictures in boxes has no cycle longer than 50
09:57 aditsu if you do the math, you find that the probability of that is about 0.312
09:58 aditsu so 31.2% chance of success :)
09:58 pdurbin if the first guy doesn't find his own picture in the first 50 tries he will be a prisoner forever. only a 31.2% chance of success?
09:59 aditsu well, if they try randomly, the chance is about 1/2^100
10:00 aditsu this is better than 1/4
10:01 aditsu it's realistic, even though not probable
10:02 pdurbin (1/2.0)**100 = 7.8886090522101181e-31 ?
10:03 aditsu yeah, something like that
10:05 pdurbin it's interesting
10:06 aditsu obviously you can't get better than 50% chances because the first guy can't get better than that
10:06 pdurbin right. makes sense
10:07 pdurbin poor prisoners
10:07 aditsu well, with this strategy, they actually have a shot
10:08 aditsu they just need a bit of luck
10:17 aditsu also this strategy works with any number of prisoners, the limit (n->∞) is 1-ln(2) ≈ 0.307
10:18 pdurbin is there a nice write up of it somewhere?
10:18 aditsu probably, let me see
10:20 aditsu pdurbin: ah, there it is: http://www.mast.queensu.ca/~peter/inprocess/prisoners.pdf
10:26 aditsu also http://forums.xkcd.com/viewtopic.php?f=3&t=7211
10:30 pdurbin ah, that pdf is great
10:31 pdurbin here's something to think about:
10:31 pdurbin given 100 documents, if you put them in various piles, how many combinations can you come up with?
10:32 pdurbin one combination could be paper #1 by itself and papers #2-100 in a separate pile
10:33 pdurbin you could have 2 even piles of 50 papers but of course you can have many variations on this
10:33 pdurbin sorry, I switched from documents to papers. same thing
10:34 pdurbin if you want the answer google for "bell number"
10:40 pdurbin our director was recently issued a patent for work along these lines: http://gking.harvard.edu/publications/method-and-apparatus-selecting-clusterings-classify-predetermined-data-set
16:36 agoddard probably a moot point, but when I looked at it again being less tired this morning,     year = year.next would create the new object as well so it wouldn't end up changing the value in the array (but I think you're already well past it by the sounds of it) ;)
16:36 agoddard codex: ^
17:01 agoddard codex: pdurbin http://pastebin.com/6b5aQgtB
17:30 codex agoddard: yea, that's what I did
17:30 agoddard codex: awnice
17:31 codex but what's strange is that the "bang" modfier ends up impating it
17:31 codex i am not understanding why when passing a variable it passes the reference instead of a clone of it
17:31 codex it seems to defeat the whole point of scoping -- which is what's happening. the "define in if being global" is just obnoxious imo
17:38 pdurbin crimsonfubot: lucky impate
17:38 crimsonfubot pdurbin: http://www.youtube.com/watch?v=E7H0zebDdO8
17:39 pdurbin :/
21:17 sivoais joined #sourcefu
21:27 sivoais joined #sourcefu
21:37 sivoais joined #sourcefu
21:47 sivoais joined #sourcefu
21:57 sivoais joined #sourcefu
22:07 sivoais joined #sourcefu
22:17 sivoais joined #sourcefu
22:27 sivoais joined #sourcefu

| Channels | #sourcefu index | Today | | Search | Google Search | Plain-Text | plain, newest first | summary

http://sourcefu.com