Live data from Hacker News

Ask HN: What's the most creative 'useless' program you've ever written?

news.ycombinator.com

351–360 of 422 posts

Re: Ask HN: What's the most creative 'useless' program you've ever written?

#351

Earlier quoted context omitted.

Also first click is never a mine (if there's one where you click it's moved to the top left corner).

Does this mean that the top left corner had a higher probability of being a mine? Or even a lower probability, seeing as the dev would have had to ensure that it's not a mine before the user clicks. Now that I think about it, the dev strategy of leaving the spot without a mine but moving one there, probably does not affect the probability that there will be a mine there during gameplay.

I don't think the dev would leave the top left without a mine until one is moved there, as that would always be a safe square to click first.

So if the probability of finding a mine at any given spot is given by p, then the probability of finding a mine in the top left during gameplay for cases where one does not click it first (in which case it is 0?) is 1 for the case where you clicked on a mine first with probability p, and then p for the remainder.

So the total probability p' is p * 1 + (1 - p) * p, or 2p - p^2.

Wikipedia says

> Beginner is usually on an 8x8 or 9x9 board containing 10 mines, Intermediate is usually on a 16x16 board with 40 mines and expert is usually on a 30x16 board with 99 mines; however, there is usually an option to customise board size and mine count.

  8x8   10 mines  p = 0.16 p' = 0.29 ratio = 1.84
  9x9   10 mines  p = 0.12 p' = 0.23 ratio = 1.88
  16x16 40 mines  p = 0.16 p' = 0.29 ratio = 1.84
  30x16 99 mines  p = 0.21 p' = 0.37 ratio = 1.79
I was curious to see the concrete effects for no reason other than to procrastinate.

Re: Ask HN: What's the most creative 'useless' program you've ever written?

#352

Earlier quoted context omitted.

Does this mean that the top left corner had a higher probability of being a mine? Or even a lower probability, seeing as the dev would have had to ensure that it's not a mine before the user clicks. Now that I think about it, the dev strategy of leaving the spot without a mine but moving one there, probably does not affect the probability that there will be a mine there during gameplay.

I don't think the dev would leave the top left without a mine until one is moved there, as that would always be a safe square to click first. So if the probability of finding a mine at any given spot is given by p, then the probability of finding a mine in the top left during gameplay for cases where one does not click it first (in which case it is 0?) is 1 for the case where you clicked on a mine first with probabil…

  > I don't think the dev would leave the top left without a mine until one is moved there, as that would always be a safe square to click first.
All squares are safe to click first, that's the point.

Re: Ask HN: What's the most creative 'useless' program you've ever written?

#355
A group of coworker friends and I used to find the most creative ways to mess with each others' computers if they were left unattended. Some of the ones I can remember off the top of my head:

1. A Chrome extension that slowly rotated every on the page (think 1 degree every 10 minutes). Would be hard to notice unless a page had been left open for a while. 2. Another Chrome extension that would redirect to a full-screen gif of John Cena that would only load after a random number of page loads. 3. A horn sound that would play after every successful git commit, regardless of computer volume. 4. A Slack bot that would scrape another coworker's insufferable Reddit comments, store them in a database, and then use ML to interject the comments into our conversations based on some basic NLP. This one was my favorite.

Re: Ask HN: What's the most creative 'useless' program you've ever written?

#356
My friend an I were struggling to orient a couch correctly during a move. We were struggling to fit it through a door. So we wrote an app called "Will it fit"

You took a picture of the piece of furniture side on. Then you could tap to draw a polygon over the image. The app would then rotate the polygon to find the orientation with the minimum width.

Re: Ask HN: What's the most creative 'useless' program you've ever written?

#357
Creative? I don't know about that, but here's something mildly interesting I did:

I came across the St. Petersburg Paradox[1] recently. The gist of this is that there's a coin-flipping game where if you go by the mathematical laws of probability, the expected payout is infinite. Meaning, you should play the game if offered the chance to play it for any finite amount of money. And yet most people will instinctively look at this and say "I wouldn't buy in to this game for more than $SOME_SMALL_AMOUNT".

To help myself understand the dichotomy, I wrote a simulation of the game in Java, and ran through 1 million rounds of playing the game, randomizing the coin flips, determining the payout, and then calculating the average.

What I found was that I wouldn't buy into this game for more than a few dollars. Because the infinite payout can only happen with infinite coin tosses as far as I can see, which would require infinite time, making that outcome irrelevant in the real world. And in a million game experiment, the average payout was usually around $20, with that outcome being highly affected by outlier outcomes. The usual outcome of individual trials was generally around $2 to $4 or so.

Useful for anything? No, but it was something fun to play around with.

[1]: http://en.wikipedia.org/wiki/St._Petersburg_paradox

Re: Ask HN: What's the most creative 'useless' program you've ever written?

#358
20 years ago, I was in the web site business. My partner and I had a customer who had a weird insistence that this site "HAVE ZERO JAVASCRIPT!" He'd heard something from someone about how it was bad, or whatever, and so was insisting we use NONE.

This made handling the forms way harder, obviously. In-page scripting to (e.g.) preserve form input properly on a failed submit, or to dynamically handle a date picker, was and remains pretty benign. So we set about creating a terrible example that would convince this guy to let us use best practices.

This meant I needed to write a perl script that created a no-javascript date picker. This date picker included an entry for every possible birthday for a user who might sign up, so it had every date from like 1/1/1930 through 12/31/1990 or whatever we figured was a reasonable boundary at the time.

We published the page and sent him a link, and in about 15 minutes we heard back. "Ok, I get it. Use scripting."

A potentially more horrifying example of programming chicanery came from the same era, when a reasonable solution to a given page problem was that I wrote Perl (using Mason) that wrote Javascript that wrote HTML.

I am not sorry.

Re: Ask HN: What's the most creative 'useless' program you've ever written?

#359
post #265
post #264

Someone made an ASCII art bonsai generator in bash, so I ported it to a few lines of JS. Then I made it animate the growth :) http://web.archive.org/web/20200512153032id_/https://andai.t... There's no "restart" button, but each refresh produces a unique tree.

Just a caution for future clickers: This caused my mobile browser to spawn a bunch of print windows and was pretty annoying to exit.

Which browser are you using?

It seems to be because I named the function that displays output print(). But it should shadow window.print(), and in most browsers it does, so I don't know what's going on!

(At any rate, this is a web archive snapshot from 2020 so I can't update the code!)

Could you try a different browser? It's not much, but it might make you smile :)

Post reply on HN