Hacker News new | past | comments | ask | show | jobs | submit | ekke's comments login

  (1.005).toFixed(2) // Expected rounding to "1.01"
  "1.00"


cases like that's everywhere.

2.875.toFixed(2) = "2.88" while 2.675.toFixed(2) = "2.67"

7205759403792794 + 1.1 = 7205759403792795

7205759403792794 + 1.9 = 7205759403792796


Hm, re: "ads are everywhere" - is it just me, or are two of the three sample posts in the screenshot content-based ads?

First for the novel Cibola Burn, and third for the app Halide.. the middle post seemingly is a reply to an ad of some book series as well :) Or "influencer" paid content != ads?


This is fascinating. For anyone interested in a slightly odd but unique and in-depth view of Systems design and failure, would like to recommend "The Systems Bible: The Beginner's Guide to Systems Large and Small" by John Gall.

https://www.amazon.com/Systems-Bible-Beginners-Guide-Large/d...


In that section, would like to add recommendations for:

- "Being Geek: The Software Developer's Career Handbook" https://www.amazon.com/Being-Geek-Software-Developers-Handbo...

- "Team Geek: A Software Developer's Guide to Working Well with Others" http://shop.oreilly.com/product/0636920018025.do -- Software engineering teamwork a-b-c. I'd love to work on teams where everyone has read this one.

[edit: 2nd edition of "Team Geek" is titled "Debugging Teams"; having read both, no difference which you get]


This is HN after all - some version of ES/JS:

  class Eel {
      valueOf () { 
          return 'https://imgflip.com/meme/Bad-Joke-Eel';
      }
  }

  const craftCapacity = 331,
        hovercraft = Array.from(Array(craftCapacity), () => new Eel);


It's "My hovercraft is full of eels", not "My hovercraft has an arbitrary amount of eels in it"!

Now looking at the ES5 spec [0], the max length of an array is an unsigned 32-bit integer due to the `ToUint32` operation that the spec defines. So that means our `craftCapacity` here needs to be 2^32-1

Sadly we can't use `Number.MAX_SAFE_INTEGER` here because that assumes double-precision floating points as the underlying storage method, so we just have to hardcode our value:

  const hovercraft = Array(4294967295).map(() => 'https://imgflip.com/meme/Bad-Joke-Eel')
[0] While the spec says this in a roundabout way, i'm not sure if any implementations actually adhere to this limit, and i'd guess most convert the array to a hashtable internally long before it gets to that size.


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.


If 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.


And if a hovercraft is an array of size 331, then it should hold 331 eels.


Ah 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.


Now 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)


While we're nitpicking, unless you have partial eels, it's arbitrary number, not amount. That calls to mind measuring blended eel, of which I don't want to make a career.


Well to be fair the saying doesn't specify the state of the eels.

It could be liquefied remains of eels! Although I'm guessing we would need to study a few of the translations in languages that explicitly differentiate between "a collection of whole somethings" and "an amount of something". Although now that I'm thinking about it in english saying "my hovercraft is full of eel" would imply that it's an amount of eel, not a distinct number of eels.

Still, if it were the "amount", a simpler JS expression would convey the message:

  const amountOfEelsInHovercraft = Number.MAX_VALUE


If they were blended, the phrase would be “my hovercraft is full of eel”


My phrase would be, "This is your hovercraft."


Whoa, whoa. Did you just assume the transitive property of sound pressure fluctuating languages with voltage fluctuating languages? You should check your access privilege.

Let me guess, I bet you think people can transmit information via the fluctuation of electromagnetic waves too. Brilliant!


NPM guys explain it in the blog today: https://news.ycombinator.com/item?id=16975025



And NPM took it down quickly, whew.


did you report it to NPM?


I don't know how many reported it to npm, but when I initially saw the post on HN, I took the steps to report the packages.

I don't know who to credit on this, and neither does npm but OP seems to be the source of these findings, although it would baffle me if they didn't report it to npm.


Sure, and at least few more people :)


Good one!

A naive strategy where they never die, and hopefully stay in prison for slightly less than a few billion years:

One prisoner is the light-counter (Mr C). Others follow a simple pattern - if the light is off, and they have never turned it on yet, turn it on. If it is already on, or they have already ever turned it on, do nothing.

Mr C enters the room, if the light is on, remembers it, and turns it off.

When Mr C has entered the room 99 times with light on, he can say 'Yes' and they are safe.

This can be optimized. How?


You have to be careful, because if the light starts out on, Mr C could be fooled when only 98 other people have entered the room.


This is essentially the same solution I came up with. I'm not sure it needs to be optimized assuming we can set the starting state and the strategy for every prisoner.


Nice photo caption fail: "Minecraft is developed by Swedish company Mojang. Will future games be developed now that Microsoft is closing its borders?"

In the light of: https://mojang.com/2014/09/yes-were-being-bought-by-microsof...


Got hooked and to 3202, but ca 10-20 more points could be gained according to answers here and there: https://gist.github.com/jonathanmorley/8058871

Kudos to the author of the game, good job.

PS. http://regexcrossword.com/


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: