9 ms·
ekke assumed the hovercraft can hold at most 331 eels. You assumed it holds 4 billion eels. Who's right? I don't know but a billion eels sounds far off.
by bebe3000 8y ago
ekke assumed the hovercraft can hold at most 331 eels. You assumed it holds 4 billion eels. Who's right? I don't know but a billion eels sounds far off.
- Klathmon 8y agoIf an array is the hovercraft, it can hold 4 billion "things" regardless of what those things are! So you need to fill that up to meet the requirements of the saying.
- simsla 8y agoAnd if a hovercraft is an array of size 331, then it should hold 331 eels.
- peeters 8y agoAh but now we're at the crux of the issue; in Javascript, hovercrafts grow in size to accommodate as many eels as you put in, but to a maximum of ~4 billion. So "full" is not a question you can ask of your hovercraft, though it will tell you once it's overflowing.
- Klathmon 8y agoNow there's a thought! What if we used a storage method that didn't grow? In JavaScript we have typed arrays, we could use a `Uint16Array` to store UTF-16 code points as integers in each element, then we could define the amount of eels that our "hovercraft" could store ahead of time in a way that it won't expand. const hovercraftEelCapacity = 331 // We can define our hovercraft to have room for 331 eels const eel = 'eel' const hovercraft = new Uint16Array(new ArrayBuffer(2 * eel.length * hovercraftEelCapacity)) // Each "eel" takes up 3 16-bit integers for (let i = 0; i < hovercraftEelCapacity * eel.length; i += eel.length) { hovercraft[i] = eel.codePointAt(0) hovercraft[i+1] = eel.codePointAt(1) hovercraft[i+2] = eel.codePointAt(2) } console.log('Your hovercraft full of eels: ', hovercraft)