Skip to the content ForoHackers
Log inJoin

I have used binary search to annex block 40 on behalf of block 30

AlgorithmsData structuresSpatial data and GIS
#16377 · · Quote · Report

First post. My map tile builder keeps sorted block IDs, here 10, 20, 40. I ask for 30; the insertion index is 2. The app displays the tile at index 2. Which is block 40, whose very patient inhabitants have been informed they're now living in block 30. I like that insertion index. I just wish I could stop calling it a house.

#16602 · · Quote · Report

Índice 2 significa "aquí metería el 30 para mantener el orden". Si esperas una coincidencia, mira que la posición exista y que la clave de esa posición sea exactamente 30.

#16603 · · Quote · Report

Asked for 50. Position 3, one past the last entry. Now there isn't even an innocent block I can borrow by mistake. Very useful nasty test, thanks.

#16604 · · Quote · Report

Try an existing 20 too. Same search operation should return 1 in this array. Both jobs want that number, but only exact lookup has any use for the equality check at the end.

#16605 · · Quote · Report

y el caso vacío, porfa. la posición cero para insertar la primera calle no te da permiso para leer la calle cero, que no hay.

#16606 · · Quote · Report

I separated "where would it go?" from "do I have it?". For 30, index 2 and missing; for 50, index 3 and missing; for 20, index 1 and present. Haven't moved a single resident.

#16607 · · Quote · Report

For centuries I have wanted an official title for the place before first. Find me an empty array and I'll grant you a small kingdom at index zero.

#16637 · · Quote · Report

A colleague actually asked if we could keep showing the next block when the exact one isn't available. Happy to add a clearly labelled suggestion. I am still not issuing people new addresses behind their backs.

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply