« Back to channel list

#ruby - 02 March 2019

« Back 1 day Forward 1 day »
[00:00:45] jyaworski: has joined #ruby
[00:01:54] Darmani: Okay I think I got it
[00:01:54] Darmani: https://gist.github.com/mfifth/46fb313965ab679409dedf1765232e52
[00:02:05] Darmani: I mean it seems to work when I try it in irb
[00:04:57] leftylink: I suddenly had a crazy thought. what if I wanted to use rubydoc to test whether someone's gist worked. how will I instruct it to load the gist... well...!!!!!!
[00:05:30] leftylink: &>> eval `curl https://gist.githubusercontent.com/mfifth/46fb313965ab679409dedf1765232e52/raw/2c27dacd91eb3817ffb3aad1ed29c19d7803ee35/app.rb`; Grade.new("A+") <=> Grade.new("A")
[00:05:32] rubydoc: stderr: -e:2:in `<main>': uninitialized constant Grade (NameError) (https://carc.in/#/r/6e7h)
[00:05:35] leftylink: I am a bad person
[00:05:41] leftylink: that is unfortunate
[00:05:46] Darmani: You tried.
[00:06:15] leftylink: does the curl part even work?
[00:06:30] leftylink: &>> `curl https://gist.githubusercontent.com/mfifth/46fb313965ab679409dedf1765232e52/raw/2c27dacd91eb3817ffb3aad1ed29c19d7803ee35/app.rb`[0, 30]
[00:06:31] rubydoc: # => "" (https://carc.in/#/r/6e7i)
[00:06:35] leftylink: okay guess not
[00:07:26] Darmani: leftylink: https://repl.it/repls/DoubleMediumorchidSystemadministrator
[00:07:57] leftylink: &>> `wget -O - example.com`[0, 30]
[00:07:57] rubydoc: stderr: -e:2:in ``': No such file or directory - wget (Errno::ENOENT) (https://carc.in/#/r/6e7j)
[00:08:30] leftylink: I can do the http get from ruby code natively but it sounds like work
[00:09:17] leftylink: &>> require 'net/http'; Net::HTTP.get('example.com', '/index.html')[0, 30]
[00:09:18] rubydoc: stderr: playpen: application terminated abnormally with signal 31 (Bad system call) (https://carc.in/#/r/6e7k)
[00:09:38] leftylink: I mean I guess that's to be expected
[00:10:16] leftylink: and it encourages people to use more minimal examples
[00:10:33] Darmani: yeah maybe
[00:10:35] leftylink: or compress their entire class into a one-liner, but nobody wants to read an entire class as a one-liner
[00:12:51] Darmani: this is better
[00:12:52] Darmani: https://gist.github.com/mfifth/46fb313965ab679409dedf1765232e52
[00:13:21] havenwood: Darmani: You can drop the `self.`
[00:13:38] Darmani: Is it implied? Okay
[00:13:45] Darmani: I just like to be thorough.
[00:14:23] havenwood: Darmani: You have a valid arguement.
[00:15:06] Darmani: Still not correct though. It thinks the "a-" is greater than an "a".
[00:15:12] Darmani: And I don't think it works like that.
[00:17:58] havenwood: Darmani: You might consider renaming `string` to `grade` for symmetry and conveying meaning.
[00:18:19] havenwood: Darmani: you need to `include Comparable`
[00:18:25] Darmani: On line 4?
[00:18:35] Darmani: Comparable isn't included??
[00:18:42] havenwood: Darmani: I'd do 2, but pick your poison.
[00:18:52] havenwood: Darmani: No, it's up to you to mix it in.
[00:19:56] leftylink: hopefully, it makes sense why the current code would (wrongly) consider "a-" to be greater than "a". that should hopefully give hints as to what it should do instead
[00:20:42] havenwood: though a- with a sword should clearly defeat a, so ¯\_(ツ)_/¯
[00:23:08] havenwood: Darmani: @grade is quicker yet than #grade, on line 13 - and it simplifies meaning for the reader
[00:23:43] havenwood: (I should have just said that immediately, multitasking)
[00:23:58] havenwood: I like using instance variables directly.
[00:24:20] Darmani: I mean why not use them?
[00:24:23] havenwood: &ri Comparable
[00:24:23] rubydoc: https://ruby-doc.org/core-2.6/Comparable.html
[00:25:01] havenwood: Darmani: They're light and quick and signify to the reader that you're getting and setting directly without having to read more.
[00:25:25] nwradio: has joined #ruby
[00:26:42] havenwood: Darmani: I usually put my includes/prepends/extends up top.
[00:27:18] Darmani: makes sense
[00:28:48] mkroman: has joined #ruby
[00:29:16] jyaworski: has joined #ruby
[00:33:49] Darmani: https://gist.github.com/mfifth/46fb313965ab679409dedf1765232e52
[00:36:00] havenwood: Darmani: Congrats! You can drop the `return`s
[00:36:59] leftylink: the reason you should be suspicious is that you notice that the result of <=> depends nothing on `other_grade`
[00:37:00] jyaworski: has joined #ruby
[00:37:14] leftylink: which will mean that C <=> A will surely give the same result as C <=> F
[00:37:33] leftylink: which should cause suspicion
[00:37:35] leftylink: to put it lightly
[00:38:09] Darmani: hmmm you're right
[00:38:44] havenwood: Darmani: Also a bit opposite on the +/0
[00:39:11] Darmani: What is that?
[00:39:19] havenwood: + with +, - with -
[00:39:32] havenwood: you have + with -, - with +
[00:39:48] havenwood: Darmani: Grade.new("+") > Grade.new("-") #=> false # problem
[00:47:33] leftylink: as it has been made apparent, sorting solely on letter doesn't work. and sorting solely on the symbol doesn't work, because then C+ <=> A- will surely give the same answer as C+ <=> D-
[00:49:34] Darmani: So we have to combine the two? And check that way?
[00:53:46] leftylink: thus, we see it is necessary to consider both of those components when sorting
[00:53:50] leftylink: or comparing, rather
[00:55:01] DarthGandalf: has joined #ruby
[00:56:16] bmurt: has joined #ruby
[01:04:09] Darmani: Okay so I thought this would work and it did if I only gave it one grade
[01:04:11] Darmani: https://gist.github.com/mfifth/46fb313965ab679409dedf1765232e52
[01:04:20] Darmani: But if I give it two grades then it messes up for some reason.
[01:04:54] Darmani: nvm I'm just confused
[01:15:49] tdy: has joined #ruby
[01:28:28] leftylink: you know, I was presenting this as a primary+secondary sort kind of thing, but it occurs to me that converting each possible grade to a number would work as well for this purpose
[01:29:22] leftylink: at any rate, it seems prudent to test each combination of possible grades. if we are to assume they can only go from A to F, there are so few of them that one should do it exhaustively
[01:29:34] leftylink: with something like
[01:30:01] leftylink: %w(A+ A A- B+ B B- C+ C C- D+ D D- F).map { |g| [g, Grade.new(g)] }.combination(2) { |(s1, g1), (s2, g2)| puts "#{s1} should > #{s2}" unless g1 > g2; puts "#{s2} should be < #{s1}" unless g2 < g1 }
[01:30:48] Darmani: Yes I see that.
[01:57:43] mad_hatter: has joined #ruby
[01:58:16] mad_hatter: Does anyone have any general ideas/can point me to a good doc/tutorial for how to go about implementing integration/unit tests into a code base without any for the purposes of CI/CD?
[01:58:55] Xiti: has joined #ruby
[02:05:06] mad_hatter: has joined #ruby
[02:05:13] mad_hatter: Does anyone have any general ideas/can point me to a good doc/tutorial for how to go about implementing integration/unit tests into a code base without any for the purposes of CI/CD?
[02:05:36] havenwood: mad_hatter: Are you familiar with Minitest?
[02:05:57] havenwood: bambanx: hi
[02:06:05] bambanx: howdy havenwood ?
[02:06:24] bambanx: i wrote well?
[02:06:27] bambanx: i am not native english
[02:06:33] bambanx: spanish from chile
[02:06:53] bambanx: i am old here tho
[02:07:00] havenwood: welcome back!
[02:07:02] bambanx: like15 years ago
[02:07:39] mad_hatter: havenwood: i am not
[02:08:09] havenwood: mad_hatter: Minitest is the testing library that ships with Ruby.
[02:08:12] havenwood: mad_hatter: https://github.com/seattlerb/minitest#unit-tests
[02:08:39] havenwood: mad_hatter: Minitest and RSpec are the two most popular Ruby testing gems.
[02:14:54] havenwood: mad_hatter: https://gist.github.com/havenwood/8628f94348f15433336f021d309da39b
[02:16:37] Renich_: has joined #ruby
[02:24:14] Darmani: Okay so this isn't correct but I don't know what is
[02:24:15] Darmani: https://gist.github.com/mfifth/46fb313965ab679409dedf1765232e52
[02:24:34] Darmani: How do you tell the operator how to judge to values at the same time? Or am I supposed to lookup one value and then the other value.
[02:24:38] Darmani: Separate them somehow?
[02:26:02] Darmani: Obviously it should check the letter and then the symbol but I don't know how I would write it.
[02:26:58] johnny56_: has joined #ruby
[02:28:00] mangold: has joined #ruby
[02:37:28] orbyt_: has joined #ruby
[03:00:26] ogres: has joined #ruby
[03:29:27] jyaworski: has joined #ruby
[03:52:09] dviola: has joined #ruby
[03:53:16] cschneid: has joined #ruby
[04:03:00] jyaworski: has joined #ruby
[04:06:41] Dreamer3: has joined #ruby
[04:09:15] braincrash: has joined #ruby
[04:15:43] rprimus: has joined #ruby
[04:24:44] cschneid: has joined #ruby
[04:44:51] jyaworski: has joined #ruby
[04:49:00] crankharder: has joined #ruby
[04:50:26] bambanx: why ruby people is friendly?
[05:01:46] tdy: has joined #ruby
[05:18:14] al2o3-cr: &>> trap(:XCPU) { abort "[TIMED OUT]" }; Process.setrlimit(:CPU, 2, -1); loop {}
[05:18:19] rubydoc: stderr: playpen: application terminated abnormally with signal 31 (Bad system call) (https://carc.in/#/r/6e9o)
[05:23:48] aqd: has joined #ruby
[05:24:58] aqd: has joined #ruby
[05:47:00] t0x: has joined #ruby
[05:51:11] _whitelogger: has joined #ruby
[05:54:10] cschneid: has joined #ruby
[05:56:54] rippa: has joined #ruby
[05:56:55] arekushi: has joined #ruby
[06:10:06] aspiers: has joined #ruby
[06:20:19] vdl: how do I parse an INI like configuration file in Ruby? (pretty basic, no string quoting, multiple sections with the same name allowed)
[06:25:12] al2o3-cr: vdl: you could use the inifile gem
[06:26:31] Autolycus: has joined #ruby
[06:31:46] sauvin: has joined #ruby
[06:33:32] mniip: has joined #ruby
[07:27:34] jyaworski: has joined #ruby
[07:27:51] mangold: has joined #ruby
[07:30:35] Puffball: has joined #ruby
[07:38:12] kapil____: has joined #ruby
[07:45:07] blackmesa: has joined #ruby
[07:52:31] reber: has joined #ruby
[08:01:35] jyaworski: has joined #ruby
[08:08:19] wilbert: has joined #ruby
[08:10:55] ravenousmoose: has joined #ruby
[08:11:32] jyaworski: has joined #ruby
[08:15:47] fluxAeon: has joined #ruby
[08:24:53] amosbird: has joined #ruby
[08:40:40] zapata: has joined #ruby
[08:44:35] sameerynho: has joined #ruby
[08:57:11] _whitelogger: has joined #ruby
[09:01:12] al2o3-cr: has joined #ruby
[09:04:27] MyMind: has joined #ruby
[09:08:58] nwradio: has joined #ruby
[09:11:53] c-c: If I have a method that creates a class instance, its not possible to refer to that instance from a block passed into that method for yielding?
[09:12:16] Onwarion: has joined #ruby
[09:16:27] gix: has joined #ruby
[09:17:30] tbuehlmann: c-c: you can call `yield your_instance` which will run the block with that variable as block variable
[09:17:41] c-c: >class Spawner; def initialize; @foo=0; end; def spa; bar = @foo + 1; yield; end; end; s=Spawner.new; s.spa do; p bar; end
[09:17:50] c-c: &> class Spawner; def initialize; @foo=0; end; def spa; bar = @foo + 1; yield; end; end; s=Spawner.new; s.spa do; p bar; end
[09:17:50] rubydoc: parser error at position 0 around `>'
[09:18:01] Dbugger: has joined #ruby
[09:18:19] c-c: &>> "test"
[09:18:20] rubydoc: # => "test" (https://carc.in/#/r/6ebd)
[09:18:25] c-c: &>> class Spawner; def initialize; @foo=0; end; def spa; bar = @foo + 1; yield; end; end; s=Spawner.new; s.spa do; p bar; end
[09:18:26] rubydoc: stderr: -e:2:in `block in <main>': undefined local variable or method `bar' for main:Object (NameError) (https://carc.in/#/r/6ebe)
[09:18:54] blackmesa: has joined #ruby
[09:18:55] c-c: (so I'm after bar, in the spa do; end; -block)
[09:19:14] tbuehlmann: https://gist.github.com/tbuehlmann/dd07be2f539cc8c7fc927df2eef2b04a
[09:20:35] bruce_lee: has joined #ruby
[09:22:11] aqd: has joined #ruby
[09:29:09] laaron: has joined #ruby
[09:30:10] Fusl: has joined #ruby
[09:30:55] cd: has joined #ruby
[09:33:16] cnsvc_: has joined #ruby
[09:33:47] znz_jp: has joined #ruby
[09:36:03] c-c: Ok, that works (note: debug code) https://gist.github.com/csmr/5c0da68094e8112c4624f457f180be24#file-pipedprocs-rb-L244
[09:51:53] connor_goodwolf: has joined #ruby
[09:54:30] cschneid: has joined #ruby
[10:13:10] marmotini_: has joined #ruby
[10:16:41] themsay: has joined #ruby
[10:25:52] TomyLobo: has joined #ruby
[10:28:31] wildermind: has joined #ruby
[10:30:24] conta: has joined #ruby
[10:34:41] ravenousmoose: has joined #ruby
[10:39:54] phaul: leftylink: if you come up with a way on carc.in to load a gist, I integrate it into rubydoc the same way as &ast>>, &asm>> etc works it could be &gist>>
[10:46:09] jyaworski: has joined #ruby
[10:50:48] clemens3: has joined #ruby
[10:51:15] Fernando-Basso: has joined #ruby
[11:04:29] sacomo: has joined #ruby
[11:13:41] al2o3-cr: phaul: what do you mean? grab the gist content and evaluate it on carc.in?
[11:14:01] phaul: yeah, that's what leftylink was playing with ^
[11:14:13] phaul: it's a good idea, but I don't think it's possible
[11:14:29] phaul: I mean grabbing it using carc.in
[11:14:42] al2o3-cr: oh, right, yes. that will be handy ;)
[11:15:24] phaul: but.. I could grab it myself. that shouldn't be security risk. It's just web requests, based on strings.
[11:15:40] phaul: yeah. ok. I'll do this
[11:16:06] al2o3-cr: sure. pretty positive carc.in is well sandboxed.
[11:19:22] ellcs: has joined #ruby
[11:22:09] lucasb: has joined #ruby
[11:28:53] mangold: has joined #ruby
[11:42:41] jyaworski: has joined #ruby
[11:47:41] dionysus70: has joined #ruby
[11:54:56] TheBloke: has joined #ruby
[11:58:16] mangold: has joined #ruby
[12:00:12] nowhereman: has joined #ruby
[12:03:00] jyaworski: has joined #ruby
[12:09:01] conta: has joined #ruby
[12:12:11] _whitelogger: has joined #ruby
[12:12:52] jyaworski: has joined #ruby
[12:20:20] BOOGIEMAN-pN: has joined #ruby
[12:23:39] ravenousmoose: has joined #ruby
[12:25:25] cschneid: has joined #ruby
[12:32:53] BOOGIEMAN-pN: has left #ruby: ()
[12:47:05] jyaworski: has joined #ruby
[13:05:15] AJA4350: has joined #ruby
[13:13:24] aqd: has joined #ruby
[13:16:36] kitikonti: has joined #ruby
[13:22:17] aqd: has joined #ruby
[13:28:15] ellcs: has joined #ruby
[13:36:11] _whitelogger: has joined #ruby
[13:48:33] wildermind: has joined #ruby
[14:10:29] dionysus70: has joined #ruby
[14:14:58] minimal_life: has joined #ruby
[14:28:08] dionysus70: has joined #ruby
[14:38:10] TheBloke: has joined #ruby
[14:40:10] conta: has joined #ruby
[14:41:22] ams__: has joined #ruby
[14:48:10] jyaworski: has joined #ruby
[14:49:42] ravenousmoose: has joined #ruby
[14:54:57] cschneid: has joined #ruby
[15:01:17] conta: has joined #ruby
[15:03:09] kitikonti: has joined #ruby
[15:29:47] jyaworski: has joined #ruby
[15:40:34] laaron: has joined #ruby
[15:45:13] ravenousmoose: has joined #ruby
[15:46:05] ravenousmoose: has joined #ruby
[15:51:37] tdy: has joined #ruby
[15:58:13] Darmani: has joined #ruby
[15:59:18] Darmani: Hi everyone! I'm trying to write a comparable method for my object class but I'm not really sure how to go about it.
[15:59:19] Darmani: https://gist.github.com/mfifth/46fb313965ab679409dedf1765232e52
[15:59:37] Darmani: I need to compare each object by their letter grade and symbol.
[16:04:01] jyaworski: has joined #ruby
[16:11:56] szulak_: has joined #ruby
[16:13:55] jyaworski: has joined #ruby
[16:15:42] rprimus: has joined #ruby
[16:22:22] al2o3-cr: &>> class Grade include Comparable; attr_reader(:grade); def initialize(grade) @grade = grade end; def <=>(other) other.grade <=> @grade end end; g1 = Grade.new('A'); g2 = Grade.new('B'); g1 > g2
[16:22:24] rubydoc: # => true (https://carc.in/#/r/6eea)
[16:24:16] al2o3-cr: &>> class Grade include Comparable; attr_reader(:grade); def initialize(grade) @grade = grade end; def <=>(other) other.grade <=> @grade end end; g1 = Grade.new('A'); g2 = Grade.new('B'); g3 = Grade.new('C'); g2.between?(g3, g1)
[16:24:16] rubydoc: # => true (https://carc.in/#/r/6eeb)
[16:25:48] al2o3-cr: doing it this way because of lexicology.
[16:26:04] Darmani: a12o3-cr: What if the grades has symbols?
[16:26:10] Darmani: Like + or - ?
[16:26:13] Darmani: Would that still work?
[16:26:54] al2o3-cr: oh, hang on.
[16:27:06] Darmani: It wouldn't I think it looks too simple.
[16:27:43] al2o3-cr: ah, i think in this case it does work.
[16:28:01] Darmani: Well yeah in the test case you provided
[16:28:29] al2o3-cr: no, should work for all.
[16:28:30] Darmani: It's not as simple as other.grade <=> @grade though. Also that filters them backwards.
[16:28:42] Darmani: I think it's supposed to be @grade <=> other.grade if anything.
[16:30:34] Darmani: https://repl.it/repls/PitifulCalculatingFormats <- So when I try this with multiple grades that have letters it puts the "A-" grade first, then "A+", then "A".
[16:30:46] Darmani: So I don't see how that works at all.
[16:32:26] Darmani: I'm about to give up though. This shit is starting to irritate me.
[16:32:49] al2o3-cr: Darmani: ah, yeah, wasn't thinking of that.
[16:33:21] Darmani: All good. I thought that was the solution too to begin with.
[16:34:35] Cthulu201: has joined #ruby
[16:36:34] Darmani: This kind of works as long as you keep all the grades the same letter.
[16:36:36] Darmani: https://gist.github.com/mfifth/46fb313965ab679409dedf1765232e52
[16:41:38] cschneid: has joined #ruby
[16:44:19] c-c: Ok I have Ale for (n)vim and it seems to pinpoint problems long before I even save. Also, I added airline. What other vim plugs do you use? (I don't use plugin installers, git svn etc use from terminal, so I won't need those)
[16:45:33] ravenousmoose: has joined #ruby
[16:46:11] al2o3-cr: Darmani: are you sure that works as you think?
[16:46:29] Darmani: No not even close
[16:46:41] Darmani: It's just what I have so far.
[16:47:41] al2o3-cr: A+ > A == true; B- > C == true ??
[16:49:07] Darmani: A b- would be greater than a C that's correct.
[16:51:30] reber: has joined #ruby
[16:54:08] cschneid: has joined #ruby
[16:56:47] ua_: has joined #ruby
[16:57:34] canton7: Darmani, you need to parse the grade into the letter, and the '+' or '-'. First compare the letters. If they're the same, compare the '+' or '-'
[16:58:07] TheBloke: has joined #ruby
[16:58:24] joaumg: has joined #ruby
[16:59:14] Darmani: canton7: I came to the same conclusion but I'm still missing something.
[16:59:15] Darmani: https://gist.github.com/mfifth/46fb313965ab679409dedf1765232e52
[16:59:46] canton7: Darmani, again, you need to parse the grade into the letter, and the '+' or '-'. You don't parse out the letter.
[17:00:19] Darmani: That's not parsing out the letter it's parsing out the symbol.
[17:00:29] Darmani: canton7: Then it compares the letter to see if they match.
[17:00:38] Swyper: has joined #ruby
[17:01:20] Darmani: Unless I'm confused which I might be.
[17:01:25] ravenousmoose: has joined #ruby
[17:01:59] canton7: Darmani, shall I just keep repeating what I said? I don't think I'm getting anywhere here
[17:02:20] canton7: "Do it this way" "Yes, I'm doing it a different way" "I suggested doing it this way" "I know, I'm doing it a different way"
[17:02:47] Darmani: canton7: If it was as simple as "do this" I obviously would have done that by now.
[17:02:58] Darmani: If I knew what you were talking about
[17:03:01] Darmani: I might actually do it.
[17:03:06] Darmani: I appreciate the advice though.
[17:03:22] canton7: well it really is as simple as I described. If you don't understand what I'm describing, ask: don't say "I came to the same conclusion"...
[17:03:44] Darmani: The same conclusion to compare the letters and then compare the symbols?
[17:03:49] Darmani: That's pretty easy to understand.
[17:04:50] canton7: I said to parse out the letter and the symbol. *first* compare the letters, *then* if the letters are the same, look at the symbols
[17:05:13] canton7: so step 1: create variables containing the letter, and the symbol
[17:05:25] canton7: step 2: compare the variables containing *just* the letters. No symbols.
[17:05:40] canton7: step 3: *if* and only if the letters match, then compare the variables containing *just* the symbols
[17:06:28] Darmani: canton7: And then apply -1, 1, 0 accordingly?
[17:07:22] canton7: Yes. If the letters are *not* the same, return -1 or 1 as appropriate. If the letters are the same, compare the symbols and return -1, 0, or 1 as appropriate
[17:08:26] Darmani: canton7: okay that seems pretty straightforward.
[17:20:26] cyberRodent: has joined #ruby
[17:20:28] uranoss: has joined #ruby
[17:22:05] Darmani: canton7: Dude
[17:22:12] Darmani: I will literally give you money for helping me solve this
[17:22:14] Darmani: where do I donate lol
[17:22:37] yxhuvud: has joined #ruby
[17:22:49] Darmani: Also here's the finished product, it could probably be cleaned up a little more but it works
[17:22:50] Darmani: https://gist.github.com/mfifth/46fb313965ab679409dedf1765232e52
[17:25:01] orbyt_: has joined #ruby
[17:25:31] TheBloke: has joined #ruby
[17:25:51] cyberRodent: has joined #ruby
[17:26:21] AJA4350: has joined #ruby
[17:30:48] canton7: Darmani, https://repl.it/repls/WeakRunnyMachinecodeinstruction
[17:32:22] Darmani: Very clean.
[17:33:42] canton7: and if you're serious about the money: https://secure.msf.org.uk/Donate/ :)
[17:34:29] Darmani: Thanks man :)
[17:40:09] cschneid: has joined #ruby
[17:48:33] cyberRodent: has joined #ruby
[17:52:56] wildermind: has joined #ruby
[17:55:38] nwradio: has joined #ruby
[17:56:14] Darmani: canton7: What about finding the longest substring in a string? Is there any good articles for that sort of thing?
[17:56:32] canton7: that's a classic programming problem
[17:56:41] canton7: comes up in all sorts of online code challenge thingies
[17:57:36] Darmani: canton7: Is there an elegant solution?
[17:57:42] Darmani: Because most of the ones I see look like shit
[17:58:05] canton7: which variant of the problem is yours?
[17:58:44] Darmani: implement an algorithm that when given a string, returns the longest repeating substring found in the input. E.g., in the string "phenomenal", the longest repeating substring is "en".
[17:59:07] Darmani: Not too complicated but I've never solved this problem before so I don't know where to start.
[17:59:20] canton7: iirc they're all slightly gnarly
[17:59:38] blackmesa: has joined #ruby
[17:59:40] canton7: oh, longest repeating substring, not longest substring without repeating characters
[18:00:03] Darmani: yeah this is a pretty basic one I think
[18:00:23] canton7: you can do it yourself, by hand, right?
[18:01:46] Darmani: Well I've never done this before but I have an idea on how it would be solved...
[18:02:16] canton7: do it by hand, with pencil and paper. Then analyze how you did it
[18:02:30] canton7: turn that into a set of instructions on how to do it, then turn that into code
[18:02:46] Darmani: With a pencil and paper? What do you mean?
[18:03:09] canton7: get a physical pencil and a piece of physical paper :)
[18:03:27] Darmani: What do I do with those things? lmao I think I know what a substring is
[18:03:28] canton7: then use them to find the longest common substring in a word
[18:03:41] canton7: then come up with a set of instructions on how to do it, and write them down
[18:03:59] Darmani: Well I guess starting from the beginning couldn't hurt
[18:04:03] Darmani: Thanks ^_^
[18:04:15] canton7: that's the starting point for any algorithm
[18:04:25] canton7: I always start by sketching things out in a logbook
[18:05:18] Darmani: I usually just stare at my computer until my eyes hurt
[18:05:21] Darmani: works every time
[18:10:40] c-c: surprising that all kinds of tech has gone into computers, but note scribbling as a creative efforte is still smoother on pen&paper or whiteboard
[18:12:20] canton7: if you're solving "phenomenal" by hand, what do you do? you start at the 'p': uh, no other p's. Same with the 'h'. Reach the 'e': ooh another e! And they've both got 'n' after them, but that's all. The 'n' was part of 'en' so we can skip that. Onto the 'o'...
[18:13:21] c-c: so a char is a substring
[18:13:26] c-c: or do you need n > 1
[18:13:45] canton7: dunno. It doesn't matter: it's the same algorithm, one just has a step to reject substrings of length 1 at the end
[18:14:17] Darmani: canton7: So you count the characters which show up at least twice in a string and then you examine the characters next to them and so on and so forth until you have your string?
[18:14:27] jaddison: has joined #ruby
[18:14:41] canton7: that's one way of doing it, sure
[18:14:55] canton7: there will be neater ways - googling gave a couple of very terse recursive solutions
[18:15:24] Darmani: Seeing as this is my first time solving this problem I'd like to just figure it out before I get creative.
[18:23:12] wilbert: has joined #ruby
[18:26:24] wilbert_: has joined #ruby
[18:27:12] Darmani: canton7: Did you go to school for this?
[18:27:31] mamantoha: has joined #ruby
[18:27:46] canton7: I did electronics at uni, which had some programming in it
[18:28:48] Darmani: I feel like such a fake sometimes
[18:29:04] canton7: figuring out simple algorithms like this is just practice. coming up with the perfect solution requires a bunch of data structures and algorithms knowledge, which a cs uni course will give you
[18:29:40] Darmani: Yeah I guess.
[18:30:15] c-c: has joined #ruby
[18:34:46] conta: has joined #ruby
[18:35:36] AJA4350: has joined #ruby
[18:36:00] dinfuehr_: has joined #ruby
[18:37:11] am0123: has joined #ruby
[18:38:52] mamantoha: has joined #ruby
[18:44:14] hiroaki_: has joined #ruby
[18:45:04] cschneid: has joined #ruby
[18:52:00] al2o3-cr: canton7: what language?
[18:52:10] canton7: what language what?
[18:52:11] jyaworski: has joined #ruby
[18:52:26] al2o3-cr: "I did electronics at uni, which had some programming in it"
[18:52:44] canton7: ah, a combination of C and C#
[18:54:08] al2o3-cr: do you still practice these now?
[18:54:42] al2o3-cr: or stick to interpreted languages?
[18:54:54] canton7: yep, they're the two languages I'm paid to write. C for embedded stuff, C# for desktop stuff
[18:55:14] al2o3-cr: oh, cool. :)
[18:55:34] canton7: I picked up ruby at school because it was fun, and still use it for scripts / build scripts / etc, but I don't build anything serious in it
[18:56:54] al2o3-cr: that must of been a long time ago ;) jk hehe
[18:59:01] al2o3-cr: canton7: i've seen you around for like an eternity.
[19:01:53] al2o3-cr: i remember when the eval bot in here used to be named al2o3cr going back a few years now ;)
[19:03:23] ravenousmoose: has joined #ruby
[19:06:29] canton7: heh, that's probably before me time!
[19:08:16] jaddison: has joined #ruby
[19:09:11] al2o3-cr: yeah, hehe :)
[19:12:47] jaddison: has joined #ruby
[19:21:54] sacomo: has joined #ruby
[19:23:41] ravenousmoose: has joined #ruby
[19:25:18] Darmani: canton7: okay I gave up
[19:25:21] Darmani: pls dont hate me
[19:27:49] canton7: did you figure out how to do it by hand? could you describe to someone else how to do it by hand?
[19:28:52] Darmani: I think so.
[19:29:01] Darmani: I can try to explain it.
[19:29:03] wilbert: has joined #ruby
[19:30:14] canton7: right, so write that down in a gist
[19:30:26] canton7: (going to be afk in about 10 mins - dinner is cooking)
[19:31:42] jyaworski: has joined #ruby
[19:33:04] Hanmac1: has joined #ruby
[19:33:34] Darmani: canton7: https://gist.github.com/mfifth/70a7e77ba2da16412d473000bca1f18f
[19:33:41] Darmani: That's my understanding of it.
[19:33:47] Darmani: A poor man's understanding of it probably
[19:34:58] dviola: has joined #ruby
[19:36:05] laaron: has joined #ruby
[19:38:59] jaddison: has joined #ruby
[19:39:39] jaddison: has joined #ruby
[19:40:23] jaddison: has joined #ruby
[19:41:16] jaddison: has joined #ruby
[19:41:56] jaddison: has joined #ruby
[19:41:57] sagax: has joined #ruby
[19:42:26] canton7: Darmani, I'll look in a bit. No cheating: this is my super-naive O(n^3) attempt, just implementing what I'd do by hand: https://repl.it/repls/TallAstonishingGreyware
[19:43:04] wilbert_: has joined #ruby
[19:43:23] Darmani: canton7: yeah that's exactly what I was thinking!!
[19:44:48] cristof: has joined #ruby
[19:45:03] jaddison: has joined #ruby
[19:51:56] cschneid: has joined #ruby
[19:53:14] orbyt_: has joined #ruby
[19:53:34] lucasb: has joined #ruby
[20:04:43] jyaworski: has joined #ruby
[20:05:46] Renich: has joined #ruby
[20:10:04] t0x: has joined #ruby
[20:12:22] sariyar_: has joined #ruby
[20:14:32] jyaworski: has joined #ruby
[20:23:41] xrexeon: has joined #ruby
[20:28:46] ravenousmoose: has joined #ruby
[20:54:36] jyaworski: has joined #ruby
[20:57:19] tdy: has joined #ruby
[21:02:33] jaddison: has joined #ruby
[21:32:16] jaddison: has joined #ruby
[21:32:58] jaddison: has joined #ruby
[21:33:57] jaddison: has joined #ruby
[21:34:02] AJA4350: has joined #ruby
[21:34:38] jaddison: has joined #ruby
[21:36:53] jaddison: has joined #ruby
[21:38:27] houhoulis: has joined #ruby
[21:44:46] udiudi: has joined #ruby
[21:50:36] iNs: has joined #ruby
[21:55:37] Nicmavr: has joined #ruby
[21:57:12] anothertorusr: has joined #ruby
[22:02:04] cd: has joined #ruby
[22:26:32] hightower2: has joined #ruby
[22:32:59] wilbert: has joined #ruby
[22:37:09] blackmesa: has joined #ruby
[22:41:14] orbyt_: has joined #ruby
[22:41:32] jetchisel: has joined #ruby
[22:45:47] dtzuzu: has joined #ruby
[22:46:27] AJA4350: has joined #ruby
[23:00:00] nowhereman: has joined #ruby
[23:04:49] blackmesa1: has joined #ruby
[23:13:54] dviola: has joined #ruby
[23:24:41] orbyt_: has joined #ruby
[23:52:49] catbusters: has joined #ruby
[23:53:31] AJA4351: has joined #ruby