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
<?php | |
function html_implode(array $array) | |
{ | |
$callback = fn ($key, $value) => $key . '="' . (is_array($value) ? implode(' ', $value) : $value) . '"'; | |
return implode(' ', array_map($callback, array_keys($array), array_values($array))); | |
} |
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
#https://www.reddit.com/r/dailyprogrammer/comments/6k123x/20170629_challenge_321_intermediate_affine_cipher/ | |
# Keys are coprimes to 26, values are that coprime's multiplicative modular inverse | |
# since we are only ever using these coprimes, theres no need to calculate them | |
COPRIMES = { | |
3 => 9, | |
5 => 21, | |
7 => 15, | |
11 => 19, | |
15 => 7, |
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
class Cipher | |
@@characters = '#_23456789abcdefghijklmnopqrstuvwxyz' | |
@@vectors = nil | |
def self.getVector(char) | |
return self.vectors[char.downcase] | |
end | |
def self.vectors() | |
self.buildVectors() unless @@vectors |
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
# https://www.reddit.com/r/dailyprogrammer/comments/8jcffg/20180514_challenge_361_easy_tally_program/ | |
players = {} | |
ARGV[0].split(//).each do |char| | |
name = char.downcase | |
players[name] = 0 if !players[name] | |
players[name] -= 1 if char == char.upcase | |
players[name] += 1 if char == char.downcase | |
end |