Police issue update after emergency services swarm supermarket car park
Diddy receives earliest release date yet as his time behind bars is reduced AGAIN amid years-long prison sentence
Buckingham Palace staff are given alcohol awareness course after 'drunk' housemaid was arrested
Heroic scuba diver who helped rescue Thai football team trapped in flooded cave dies aged 44
Emma Willis responds to Strictly criticism with cryptic post about 'being judged' after live show suffered rating slump
Inside the abandoned Scottish island where time stands still - and its surprising link to Italy dating back to World War Two
NIGEL FARAGE: The State pension is not a handout. To break the contract with retirees now is a betrayal
'We thought we would have a lifetime': Mother-of-three whose carpenter husband unexpectedly died midway through house renovation has her 'chaotic' home transformed by hundreds of volunteers on DIY SOS
Death row inmate refuses last meal after losing final attempt to halt execution for gruesome murder of teenage rival in jealous fit of rage
Moment joyriding balaclava-clad teenage e-bikers leave father-of-seven with life-changing injuries after smashing into him at high speed
From inappropriate photos to 'sushi terrorism': The worst-behaved influencers abroad as the Ingham Family face backlash over Auschwitz video
Kate Moss looks glamorous in a black velvet maxi dress as she joins daughter Lila and Rosie Huntington-Whiteley for the Saint Laurent show during Paris Fashion Week
Spectre bug is back, this time to haunt JIT engines
Henry Nowak's killer is allowed to appeal his sentence after he was ordered to serve 21 years in jail for stabbing 18-year-old student to death
The Night Sky Is Getting 10% Brighter Every Year
Read more of this story at Slashdot.
I've already seen Digger twice...this is bold and often brilliant film-making: BRIAN VINER reviews Tom Cruise's latest film
CodeSOD: Quite a Distance from the Right Solution
Fritz's team needed to see if one point was within a certain distance from a center point. You or I would likely try and answer this question using a simple distance calculation, since that's the question we're trying to answer. But what if you didn't understand distances at all? Then you could write this little piece of genius.
private bool IsWithin(Point point, int radius) { for (int x = -radius; x < radius + 1; x++) { for (int y = -radius; y < radius + 1; y++) { if ((PositionX == point.X + x) && (PositionY == point.Y + y)) return true; } } return false; }This limits us to integer point values, which itself is fine. This iterates across every coordinate from (x-radius,y-radius) to (x+radius,y+radius) and checks if any of them are equal to our center point, (PositionX,PositionY). Notably, this means we're not checking a radius, at least not in a traditional metric, we're checking a box (or using the taxicab metric). Which if we wanted to check a box, we actually have even easier math than the distance equation- we could do that with pure bounds checking.
I've never thought to try and brute force distance checking, and that feels like a failure of my own creativity. Fritz's team mate at least was able to WTF in a way I wouldn't have considered.