Skip to content

Instantly share code, notes, and snippets.

@henrymazza
Created September 10, 2021 19:01
Show Gist options
  • Save henrymazza/d6e0f26365c720592abe9223d70efff3 to your computer and use it in GitHub Desktop.
Save henrymazza/d6e0f26365c720592abe9223d70efff3 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
class Hello
def self.world
'helloworld'
end
def self.rand_list(length, lowerb, upperb)
0.upto(length - 1).map do
rand(lowerb..upperb)
end
end
def self.capscrumble(input)
# combinatorial possibilities
rr = (0..(2**input.length)).map do |i|
bit_mask = "%0#{input.length}d" % i.to_s(2) # "1100"
input.chars.map.with_index do |char, j|
bit_mask[j] == '1' ? char.upcase : char.downcase
end.join
end[0..-2]
puts rr.join('; ')
rr
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment