Hacker News new | ask | show | jobs
by chrismorgan 2459 days ago
The five shortest ones (11, 13, 13, 13 and 13 characters long):

> 874. Carve meat.

> 5221. Dig trenches.

> 8361. Graft plants.

> 10799. Align wheels.

> 16441. Shampoo hair.

And the five longest ones (291, 305, 308, 317 and 332 characters long):

> 6231. Keep abreast of government regulations and emerging Web technology to ensure regulatory compliance by reviewing current literature, talking with colleagues, participating in educational programs, attending meetings or workshops, or participating in professional organizations or conferences.

> 12863. Design, develop, select, test, implement, and evaluate new or modified informatics solutions, data structures, and decision-support mechanisms to support patients, health care professionals, and their information management and human-computer and human-technology interactions within health care contexts.

> 7530. Keep abreast of game design technology and techniques, industry trends, or audience interests, reactions, and needs by reviewing current literature, talking with colleagues, participating in educational programs, attending meetings or workshops, or participating in professional organizations or conferences.

> 4806. Direct environmental programs, such as air or water compliance, aboveground or underground storage tanks, spill prevention or control, hazardous waste or materials management, solid waste recycling, medical waste management, indoor air quality, integrated pest management, employee training, or disaster preparedness.

> 5895. Compute, retrace, or adjust existing surveys of features such as highway alignments, property boundaries, utilities, control and other surveys to match the ground elevation-dependent grids, geodetic grids, or property boundaries and to ensure accuracy and continuity of data used in engineering, surveying, or construction projects.

---

My method for determining these things (which may be of interest to some), using just my favourite text editor, rather than slurping it into a REPL for some programming language and manipulating it thus:

1. Copy the whole document to the clipboard;

2. Paste in Vim (and note at this point that lists lose their markers in favour of just a tab character, so the numbers disappear);

3. Manually remove everything that’s not the list;

4. Manually remove the tab at the start of each line with `:%s/^\t//` or block selection (this could also be done in the next step with slight modification, matching `^\t\(.\+)` and using `submatch(1)`);

5. Prefix each line with its length and the line number using `:%s/.\+/\=len(submatch(0)) . "\t" . line(".") . ". " . submatch(0)` (I actually used asterisk instead of \+, but HN formatting hates unmatched asterisks; see `:help sub-replace-\=`; another approach for the line number part alone would have been to block-insert `1.\t` on every line, then block-select all but the first, and use `g<CTRL-A>` to increment them, see `:help v_g_CTRL-A`);

6. Sort by line length with `:sort n` (since I had put it at the start of the line for convenience);

7. Optionally strip the character counts out again with `:%s/^\d\+\t//` or similar.

sub-replace-\= and v_g_CTRL-A are among my favourite not-so-well-known Vim features. They’re not useful very often, but when they are, they’re really great.

2 comments

My first chance ever to be that guy!

My solution:

  curl "https://unawaz.github.io/stochastic-hill-climbing/tasks/" \
    | awk '{ print length, $0 }' \
    | sort -n -s \
    | sed 's/<li>//' \
    | (tail -n +11 | head; tail)
Updated to remove noise.
The problem with such a pipeline is that it’s not interactive. Now if you had a REPL that would memoize the steps so that it only ever did one `curl` request, that’d be different and useful.
First,

  curl [address] > /tmp/foo
Then, build up the pipeline starting with:

  cat /tmp/foo |
(And I know this is probably "useless abuse of cat", but whatever.)
Congrats on being that guy!
How long did this take you? I don't know vim wizardry and I was curious. Took me 4 mins to do the same thing in js console:

1. copy the text 2. split by \n 3. sort by length 4. you got sorted list

I know all of this off the top of my head, so less than a minute all up. Well, except the line(".") bit; that didn’t occur to me until I’d done it manually with the help of v_g_CTRL-A, and I had forgotten about the "." argument until I looked up its docs—haven’t used it in a while.