Permalink
Browse files

Update to v0.0.4

  • Loading branch information...
nelbren committed Oct 23, 2018
1 parent 80414f9 commit b837bb11609c7159e91972b970354c5fbb5f94af
Showing with 9 additions and 16 deletions.
  1. +3 −6 heart.rb
  2. +3 −7 shift_cipher.rb
  3. +3 −3 string_rotations.rb
@@ -1,7 +1,7 @@
#!/usr/bin/ruby
# heart.ruby v0.0.3
# heart.ruby v0.0.4
# nelbren@gmail.com
# Use: ShortBlocks1
# Use: ShortBlocks2
@a = ['','','','','','','','']
8.times do |r|
@@ -21,7 +21,4 @@
7.times { |c| @a[r] += (@cb..@ce).include?(c) ? 'x' : ' ' }
end
@a.each do |r|
f = r + r.reverse
p f
end
@a.each { |r| p r + r.reverse }
@@ -1,13 +1,9 @@
#!/usr/bin/ruby
# shift_cipher_v0.0.3.rb
# shift_cipher_v0.0.4.rb
# nelbren@nelbren.com
# UseShorthandOperIn11lines
# UseBracketSyntaxIn7lines
def shift_str(x,d)
r=''
x.each_byte do |c|
r += (c == 32 ? c : (c + d > 90 ? c + d - 26 : c + d)).chr
end
r
r=''; x.each_byte{|c| r += (c == 32 ? c : (c + d > 90 ? c + d - 26 : c + d)).chr }; r
end
def cipher2text(x)
(0..25).each{|d| p "intento ##{sprintf '%02d', d}: #{shift_str(x,d)}" }
@@ -1,5 +1,5 @@
#!/usr/bin/ruby
# string_rotations_v0.0.3.rb
# string_rotations_v0.0.4.rb
# nelbren@nelbren.com
# UsingRegex
x=gets.chomp;a=[];x.each_char{|c|x.gsub!(/^(.)(.*)(.)$/, '\2\3'+c);a<<x.dup};p a
# UsingSubstringAndOnlyOneAssing
a=[];(x=gets.chomp).each_char{|c|x=x[1..-1]+c;a<<x};p a

0 comments on commit b837bb1

Please sign in to comment.