I hereby claim:
- I am cjjuice on github.
- I am veritatem (https://keybase.io/veritatem) on keybase.
- I have a public key ASCX1WJ76AdPF1MCXjUeszrCorA9Ufq-Ezh4_1YtVvOLvQo
To claim this, I am signing this object:
[179] pry(main)> n = 1000000 | |
=> 1000000 | |
[180] pry(main)> Benchmark.bm(7) do |x| | |
[180] pry(main)* x.report('1:') { ->(str) { n.times { chars = str.chars; (1..chars.length).to_a.tap { |a| chars.each_with_index { |c, i| a[-i-1] = c } }.join } }.call('r4v3n') } | |
[180] pry(main)* x.report('2:') { ->(str) { n.times { [].tap { |a| chars = str.chars; str.size.times { a << chars.pop } }.join } }.call('r4v3n') } | |
[180] pry(main)* x.report('3:') { ->(str) { n.times { str.size/2.times { |i| str[i], str[-i-1] = str[-i-1], str[i] }; str } }.call('r4v3n') } | |
[180] pry(main)* x.report('4:') { ->(str) { n.times { str.reverse } }.call('r4v3n') } | |
[180] pry(main)* end | |
user system total real | |
1: 2.626973 0.019897 2.646870 ( 2.657133) |
print_checksum() { | |
echo $1 | shasum -a 256 | |
} | |
verify_checksum() { | |
checksum=$(echo $1 | shasum -a 256) | |
if [[ $2 == "$checksum" ]]; then | |
echo "valid" | |
else | |
printf "invalid:\n$1 ($checksum)\nvs\n$2\n" |
I hereby claim:
To claim this, I am signing this object:
# write a method that takes the array of hashes as an argument and | |
# if any of the values of the element hashes are nil, | |
# remove the hash from the parent array. | |
# i.e input: [{a: 4, b: nil}, {a: 5, b: 6}, {a: nil, b: 2}] | |
# output: [{a:5, b: 6}] |
# Definition for singly-linked list. | |
# class ListNode | |
# attr_accessor :val, :next | |
# def initialize(val) | |
# @val = val | |
# @next = nil | |
# end | |
# end | |
# @param {ListNode} l1 |
# @param {Integer[]} nums | |
# @param {Integer} target | |
# @return {Integer[]} | |
def two_sum(nums, target) | |
solution = nil | |
offset = 1 | |
while solution == nil | |
nums.each_with_index do |num, i| | |
if nums[i+offset] && num + nums[i+offset] == target | |
solution = [i, i+offset] |
I hereby claim:
To claim this, I am signing this object: