Last active
October 7, 2016 14:26
-
-
Save TeWu/b4e9ad9a3e4f1b87946d84a927c589c0 to your computer and use it in GitHub Desktop.
Puzzling: Hey, they are all under 4
This file contains hidden or 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
# | |
# http://puzzling.stackexchange.com/questions/32438/hey-they-are-all-under-4 | |
# | |
require 'active_support/core_ext/array' | |
c = "222123013102101232202311300000113113" | |
def decode(base,digits) | |
digits.reverse.inject([0,[]]) {|a,e| [a[0]+1, a[1] + [e*base**a[0]]]}[1].inject(0, :+) | |
end | |
from binary string | |
.chars.map(&:to_i).in_groups_of(8).map{|x| decode(2,x)} | |
shift c22 (like rot 13) | |
(-17..17).each{|sh| p c22.chars.map{|x| (x.ord + sh).chr}.join } | |
decode(4, c.chars.map(&:to_i)).to_s.chars.in_groups_of(2).map{|x| x.join.to_i(16).chr}.join | |
c22 = c2.chars.map {|x| (x == "." ? 0 : 1).to_s}.in_groups_of(8).map{|x| x.join.to_i(2).chr}.join | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment