HNHacker News
TopNewBestAskShowJobs

jjs

1,701 karma · joined December 9, 2008

(Permission granted for Hacker Monthly to publish my comments and/or submissions.)
submissionscomments
jjs··on Clojure Protocols can extend final Java classes (like java.lang.String)
by allowing subclassing you have a larger contract you have to maintain when you want to make changes to the underlying class: rather than just the public interface, you also need to worry about the protected interface.

In other words, if you allow subclassing, then you also have to worry about the interface that you have explicitly marked visible to subclasses.

Normally a non-problem, by definition.

final is useful when sealing a class that inherits from a parent class with a protected interface, but even if "final" is reduced to an annotation (or even a comment), its presence explicitly limits your end of the API contract.

jjs··on Clojure Protocols can extend final Java classes (like java.lang.String)
protected members when everything is immutable is pointless.

Except when used to mark the boundary between a stable public API and an internal API that is free to change between releases.

jjs··on ITA Software's Hiring Puzzles
I think that's the challenge ITA wants you to solve - recursing 300 levels deep into a list of 1000 movies will literally take forever. As you can see with the 2nd linked article, brute-force just doesn't work.

You're not recursing 300 levels deep; you abandon a subpath as soon as it doesn't match.

As for the anagrams, that sounds about right (if you install an anagram generator like wordplay, you can see that it generates a similar amount of matches).

You may want to devise a compact representation for a partly calculated results list, and just show n per page, with "prev" and "next" links that encode the original phrase and the first or last phrase on the current page.

When the user clicks "next", you run the algorithm as usual, but at each step of the trie search, you only search letters that are greater or equal to the current letter in the last known phrase.

You may also train a classifier like CRM114 to recognize "funny" and "boring" phrases, and omit the boring ones (except in your "prev" and "next" links!)

jjs··on ITA Software's Hiring Puzzles
You're on the right track with the recursive dictionary search.

For the Sling Blade Runner problem, I would make a trie (http://en.wikipedia.org/wiki/Trie) out of hash tables, like this:

    trie = {
     'dracula': {'': None,
                'dead': {'and': {'loving': {'it': "Dracula: Dead and Loving It!"}}}},
     'the': {'brides': {'of': {'dracula': "The Brides of Dracula"}}},
    # ...
    }
Then, for each word in each movie title, walk the trie from the beginning until you run out of matches (no match), or run out of words (at least one match).

Your anagram server is similar, but since they're not ordered like movie titles, you have to walk your scrambled word(s) and only generate permutations that have a matching trie path.

It's also quite possible to do it for phrases, not just words.

You can cheat a little by representing your anagram as a 26-key multiset containing the number of times each letter appears (in Python, use a dict; in C, use an array of 26 integers).

For each letter that appears in your anagram multiset one or more times, make a copy of the original multiset, and recursively descend the Dictionary trie, removing each matching letter from a new copy of the multiset (they're tiny, so don't worry). For each complete word you find, add it to a list of result candidates, along with the multiset representing the remaining letters in the anagrammatic phrase.

Repeat the process for each result candidate, growing your list into a tree. Stop when you run out of matches, or when you run out of letters in your multisets. (You can set a maximum number of leftover letters to accept, if you're having trouble matching a phrase).

If you test the letters in alphabetical order, your result phrases will already be sorted.

jjs··on ITA Software's Hiring Puzzles
Until you get to multiple-word anagrammatic phrases, when it becomes a search problem.

(You could index a list of phrases the same way, but users wouldn't be able to type in their name and find out what phrases it jumbles into.)

jjs··on Android – Now Ported On The iPhone
That was just one of many, most of which simply can't be done as iPhone apps (and several of which already exist for Android).
jjs··on To Facebook the answer must be no
He must be using COBOL on Crutches.
jjs··on Android – Now Ported On The iPhone
You should've seen what was going through my head while watching the original iPhone keynote speech...

This was before we knew that the iPhone wasn't planned to ship with a native API (or that the eventual API and the phone itself would be so crippled), but for a brief, shining moment, I saw a world where everyone had a real computer in their pockets, always connected.

I really ought to go through my notes and implement some of those exuberant ideas for Android.

(To my delight, at least one of them has already been made: Google Sky Map. It's also smarter, as it uses GPS to determine where you are; my idea was to use the camera and image processing to recognize constellations).

jjs··on To Facebook the answer must be no
Dave != XML; Dave == RSS

RSS ⊂ XML

jjs··on Android – Now Ported On The iPhone
I'm excited about the prospect of seeing this on the iPad...
jjs··on Nuclear war survival skills (1987 Edition)
IN AUSTRALIA, no less...reminded frequently in school to live in fear from terror falling from the skies

http://en.wikipedia.org/wiki/Skylab

jjs··on Antimatter Triggers Largest Explosion Ever Recorded in Universe
Wouldn't the mass in the star's chewy nougat center* escape as energy at the speed of light?

(* IANAP)

jjs··on Ask HN: SOAP vs REST, which one do you prefer working with ?
REST, by a mile.

I've written programs and frameworks that handled both SOAP and REST before, and no, you can't have them, because SOAP needs to die.

jjs··on TSA to download your iTunes?
A few Universe lifetimes, and my .emacs will be all yours.

Got it: http://github.com/jrockway/dotfiles/blob/master/emacs

jjs··on Discovery In The High School Webcom Case: Guess What
You'd think they would have noticed...

http://imgur.com/hJ38i.jpg

http://imgur.com/b0KjN.jpg

jjs··on Moral judgments can be altered ... by magnets
Use the machine on yourself first.

Then you're guaranteed to make the moral decision.

jjs··on The Examined Life, Age 8
TIM (about six years), while busily engaged in licking a pot, asked, “Papa, how can we be sure that everything is not a dream?” (p. 1)

Am I Chuang-Tzu, dreaming I am a butterfly, or a butterfly, dreaming I am Chuang-Tzu?

jjs··on Video Games Can Never Be Art
His thesis reduces to: adding any interactivity to art automatically makes it Not Art.

I wonder if he's willing to make the same statements about participatory theatre.

jjs··on Where Have All the Hackers Gone?
Read it online:

http://craphound.com/littlebrother/Cory_Doctorow_-_Little_Br...

jjs··on Where Have All the Hackers Gone?
On the contrary:

http://www.google.com/search?hl=en&q=%22a%20person%20who...

jjs··on The Unix Haters Handbook
How about when your coworker is a Linux genius who is younger than Linux!
jjs··on 7,500 Online Shoppers Unknowingly Sold Their Souls
Some niggling little thing in the back of my mind is saying human remains are one of the few things explicitly prohibited by the US Postal Service.

Like this, perhaps? http://news.ycombinator.com/item?id=1270582

jjs··on I'm going to be on Mixergy today at 11am PDT
I saw the live interview and it was great.

It seems to me that the charges of fluffiness come not necessarily from "softball" questions, but from the impression that the questions are strictly softball.

Seeing you interview, it's very obvious that you're a genuinely nice guy. You couldn't hide that without changing yourself for the worse. But you don't have to, because it's an asset.

Part of this interview focused on the question of how do you make interviewees comfortable? Comfortable enough to do the interview in the first place, and comfortable enough to answer the questions openly, without fearing that the interviewer is about to spring some trap on them.

I've also noticed you tend to apologize when asking someone a question you think is tough, but it's interesting to see the reaction, almost a "No, no, I'll answer it."

For questions that are particularly salient but awkward to ask, you should continue to use that same technique to push just a bit further, both to stretch your comfort zone, and to get a feel for the real boundaries of what people are willing or even glad to answer.

jjs··on Microbial Life Found in Hydrocarbon Lake
It's much less expensive to look for other trees of life on Earth, but is there any reason why a second one on Earth would be any more likely than a first one on, say, Europa or Titan?

It might be less likely, as we (you, me, and a couple scrillion of our closest relatives) provide robust competition against any other types of life, which may, as you mention, need different chiralities of various molecules, and may have trouble digesting any portion of our biomass.

jjs··on 7,500 Online Shoppers Unknowingly Sold Their Souls
To answer those questions conclusively, you'll have to write to the Postmaster General.
jjs··on 7,500 Online Shoppers Unknowingly Sold Their Souls
To be "remains", it needn't be indelibly human, just originally human. (e.g. cremated ashes).

I don't think the rule specified that it had to be physical remains, although that would certainly make it easier to package.

jjs··on 7,500 Online Shoppers Unknowingly Sold Their Souls
They'd have a hard time getting them from U.S.-based customers: souls, being human remains, cannot be sent by US Mail.

(http://improbable.com/airchives/paperair/volume6/v6i4/postal...)

jjs··on Apple removes Scratch from iPad/iPhone/iTouch
But then the program is still not originally written in JavaScript, so no dice.

I believe he meant as a web app.

jjs··on Every Black Hole Contains Another Universe?
By definition there is only one universe.

Ontology recapitulates tautology.

jjs··on 101 Zen Stories
The old woman is a normal layperson. If the monk wanted her to act in a more enlightened way, he should have taught her how!

She's also justifiably angry. She just realized that she spent the fruits of her own decades of toil to cure a stranger's suffering, and that because of the monk's irresponsibility, the wisdom gained will die with him, and do nothing to ease humanity's suffering.

Even if she intended spend her money to help just one person, the money would be better spent on someone who is still capable of suffering.

And if the old monk hasn't actually attained enlightenment yet, then the money would be better spent on a less experienced monk much further from enlightenment, if he shows the signs of compassion that indicate that the wisdom he gains will be used to help mankind.

Why doesn't she "take it lightly", in a Zen sort of way?...

Zen isn't about taking things lightly. It's about figuring out what's important, and what's not worth worrying about. (Among other things).

Because of its roots in Mahayana Buddhism, helping everyone attain enlightenment and free themselves from suffering is very important.

And because Zen is largely agnostic towards the supernatural, including reincarnation, there is the idea that you probably only have one lifetime to (a) achieve enlightenment, and (b) help others to achieve enlightenment or at least mitigate their suffering.

So helping everyone attain enlightenment is not to save them from mythical torment in the Naraka hells, nor from the cycle of reincarnation, but rather to stop the recurring cycles of human suffering on Earth—to eventually make enlightenment available to every living person.

Story 6 is also an allusion to the parable of the burning house, which is about a father (an adult, representing someone who is enlightened) figuring out how to get his small children to drop their games and come running outside before the house burns down.

This is especially poignant in Zen, because if you attain enlightenment but do nothing to help ease the suffering of others, or at least transmit your understanding to someone who can, you have wasted your life, every minute of which is precious and irrecoverable. And hoarding enlightenment for yourself is very much like dying peacefully in your sleep while letting others burn to death.

In story 6, the monk has escaped the figurative burning house (overcoming his own suffering by attaining enlightenment in his lifetime), but has not done anything to rescue the children inside (ordinary laypeople who still suffer).

The old woman takes revenge by reversing the situation, in a more literal sense. Don't assume that the monk was outside the hut when it burned. >:)

← PreviousPage 6 of 16Next →