Created
September 10, 2021 19:01
-
-
Save henrymazza/d6e0f26365c720592abe9223d70efff3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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