Skip to main content

Timeline for Write a Playfair encryption program

Current License: CC BY-SA 3.0

18 events
when toggle format what by license comment
Jan 2, 2016 at 16:24 comment added Doorknob @daniero I can't believe I missed each_slice there. I even used it later in the code! Thanks; Ruby is finally in its rightful place: shorter than C ;)
Jan 2, 2016 at 16:22 history edited Doorknob CC BY-SA 3.0
deleted 8 characters in body
Jan 2, 2016 at 15:02 comment added daniero Oh wow, that's a lot of golfing :) I think the second line is equivalent to c=(k&k)|[*?A..?Z]-[?J] ..? And the third line is just c.each_slice(5), isn't it? :)
Jan 2, 2016 at 3:50 comment added Doorknob @daniero 115 characters later... I'm still 5 chars above the C answer >_<. See any more optimizations?
Jan 2, 2016 at 3:42 history edited Doorknob CC BY-SA 3.0
added 7 characters in body
Jan 2, 2016 at 3:19 history edited Doorknob CC BY-SA 3.0
added 70 characters in body
Jan 2, 2016 at 3:09 history edited Doorknob CC BY-SA 3.0
added 4 characters in body
Jan 2, 2016 at 2:58 history edited Doorknob CC BY-SA 3.0
deleted 30 characters in body
Jan 2, 2016 at 1:56 comment added Doorknob @daniero Haha, yeah, even I'm having trouble understanding my own code. I shaved 50 bytes off, but I'm fairly certain way more is possible; I've got to go for now though.
Jan 2, 2016 at 1:56 history edited Doorknob CC BY-SA 3.0
deleted 16 characters in body
Jan 2, 2016 at 1:54 comment added daniero Aw, you're right. I didn't fully understand the usage of m.. Dang, that's some confusing code :D
Jan 2, 2016 at 1:48 comment added Doorknob @daniero Unfortunately, tr to & on line 1 doesn't work because m can't be uniqified. However, k.uniq can be shortened to (k&k) (1 byte off).
Jan 2, 2016 at 1:46 comment added daniero Yeah, I see that :) I stumbled upon the challenge and I immediately wanted to take a stab at it in Ruby, until I saw your answer.. The complexity of the code kind of scared me out of it, but I had to take a look at it :)
Jan 2, 2016 at 1:41 comment added Doorknob @daniero Right, this was done a looong time ago, so there's probably lots more improvements I could make. Thanks for the tips; time to revisit this!
Jan 2, 2016 at 1:38 comment added daniero Using & also eliminates the need for uniq later. And the chars to array thing also applies to line 6.
Jan 2, 2016 at 1:29 comment added daniero Looks nice, but there's room for improvement: On the first line there's no need to "cast" chars into an array, assuming you're using Ruby 2. Also you can use & as a set operator instead of tr: t=->s{s.gsub(?j,?i).upcase.chars&[*?A..?Z]} (7 bytes saved). The two next lines can be joined with something like k,m=[1,2].map{t[gets.chop]} (note chop rather than chomp).
Mar 7, 2014 at 2:37 history edited Doorknob CC BY-SA 3.0
added 454 characters in body
Mar 7, 2014 at 1:48 history answered Doorknob CC BY-SA 3.0