Permalink
Browse files

Update to v0.0.3

  • Loading branch information...
nelbren committed Oct 23, 2018
1 parent d32be70 commit 80414f98e31ffb6b18f198c7c491141597cf0117
Showing with 10 additions and 14 deletions.
  1. +3 −5 heart.rb
  2. BIN shift_cipher.c.bin
  3. +4 −6 shift_cipher.rb
  4. +3 −3 string_rotations.rb
@@ -1,7 +1,7 @@
#!/usr/bin/ruby #!/usr/bin/ruby
# heart.ruby v0.0.2 # heart.ruby v0.0.3
# nelbren@gmail.com # nelbren@gmail.com
# Use: Shortened if # Use: ShortBlocks1
@a = ['','','','','','','',''] @a = ['','','','','','','','']
8.times do |r| 8.times do |r|
@@ -18,9 +18,7 @@
else else
@cb = @cb + 1 @cb = @cb + 1
end end
7.times do |c| 7.times { |c| @a[r] += (@cb..@ce).include?(c) ? 'x' : ' ' }
@a[r] += (@cb..@ce).include?(c) ? 'x' : ' '
end
end end
@a.each do |r| @a.each do |r|
BIN -7.23 KB shift_cipher.c.bin
Binary file not shown.
@@ -1,17 +1,15 @@
#!/usr/bin/ruby #!/usr/bin/ruby
# shift_cipher_v0.0.2.rb # shift_cipher_v0.0.3.rb
# nelbren@nelbren.com # nelbren@nelbren.com
# UseTernaryOperatorIn13lines # UseShorthandOperIn11lines
def shift_str(x,d) def shift_str(x,d)
r='' r=''
x.each_byte do |c| x.each_byte do |c|
na = c == 32 ? c : (c + d > 90 ? c + d - 26 : c + d) r += (c == 32 ? c : (c + d > 90 ? c + d - 26 : c + d)).chr
r=r+na.chr
end end
r r
end end
def cipher2text(x) def cipher2text(x)
p " cifrado: #{x}" (0..25).each{|d| p "intento ##{sprintf '%02d', d}: #{shift_str(x,d)}" }
(1..25).each{|d| p "intento ##{sprintf '%02d', d}: #{shift_str(x,d)}" }
end end
cipher2text('PHHW PH DIWHU WKH WRJD SDUWB') cipher2text('PHHW PH DIWHU WKH WRJD SDUWB')
@@ -1,5 +1,5 @@
#!/usr/bin/ruby #!/usr/bin/ruby
# string_rotations_v0.0.2.rb # string_rotations_v0.0.3.rb
# nelbren@nelbren.com # nelbren@nelbren.com
# UsingRotate # UsingRegex
x=gets.chomp;a=[];x.size.times{a<<x=x.chars.rotate(1).join};p a x=gets.chomp;a=[];x.each_char{|c|x.gsub!(/^(.)(.*)(.)$/, '\2\3'+c);a<<x.dup};p a

0 comments on commit 80414f9

Please sign in to comment.