I hereby claim:
- I am kentor on github.
- I am kentor (https://keybase.io/kentor) on keybase.
- I have a public key whose fingerprint is EBFF 6E66 1EB6 E094 AD5E EC64 F0F2 8A0A 7AB8 63FD
To claim this, I am signing this object:
addEventListener("fetch", (event) => { | |
event.respondWith( | |
new Response("Dirtybit.dev", { | |
status: 200, | |
headers: { "content-type": "text/plain" }, | |
}), | |
); | |
}); |
Goal is to get | |
* 7 of each resource | |
* 20 fish | |
* 2 tier 3 weapons | |
* 3 potions | |
* 520 shards | |
Try to do this in two passes with minimal item juggling. | |
First pass: |
I hereby claim:
To claim this, I am signing this object:
This (interview) question is to create a function that maps integers to excel columns. For example:
1 => A, 2 => B, ..., 26 => Z, 27 => AA, 28 => AB, ..., 52 => AZ, 53 => BA, ..., 703 => AAA
The problem is tricky because once you start thinking in terms of base 26, you're going to find out it doesn't do the mapping correctly (I've been there). You're tempted to think okay if I let
0 => A, 1 => B, ..., 25 => Z
like in base 26, then I'd just have to subtract the input number by 1 and use this mapping to get the output. But that doesn't work for the input 27
since that would map to BA (26 = 1*26 + 0)
. Indeed, you can't even get AA
using this scheme in a sane manner. This is because the conversion isn't really base 26. Perhaps rewriting the input numbers makes it clearer:
Given two sorted arrays, A of length N where N in [0, inf), and B of length M in [0, inf), find the kth smallest element in the union U = A u B in sub O(k) time.
Most of the solutions that I have googled do not consider the case where N and M can be as small as 0, but this solution does.
The strategy to this problem is to chop off part of the arrays that we know can't be the kth element. In doing so, when we recurse on the smaller arrays, the number 'k' will change to reflect tossing out elements smaller than the kth element. The base case is when either one of the arrays is empty, the kth smallest element is the the non-empty array at index k-1:
def kth_smallest(k, a, b)
return b[k-1] if a.empty?
return a[k-1] if b.empty?
class Point < Complex | |
class << self | |
alias :new :rectangular | |
end | |
end | |
class Boggle | |
require 'set' | |
attr_reader :words |
class Array | |
def qsort!(low = 0, high = self.size - 1) | |
return self if high <= low | |
pivot_idx = rand(low..high) | |
pivot = self[pivot_idx] | |
self[pivot_idx], self[high] = self[high], pivot | |
i, j = low - 1, high | |
begin |