AI 资讯
# Understanding Backtracking Through a Tetris Optimizer in Go
When I first heard the term backtracking , it sounded like a complicated algorithm reserved for computer scientists. After spending the last couple of weeks learning it and implementing it in a Tetris Optimizer project, I realized something surprising: Backtracking is simply the art of making a decision, checking whether it works, and if it doesn't, undoing it and trying something else. This article explains backtracking using a practical project instead of abstract examples. The Problem Imagine you have several Tetris pieces (tetrominoes), and your goal is to fit all of them into the smallest possible square . It might look something like this: A A A A B B B B C C C C D D D D The challenge is to arrange every piece so that: No pieces overlap. No piece extends outside the board. Every piece is used exactly once. The board is as small as possible. This is much harder than it looks. My First Thought Initially, I thought I could simply place one piece after another. Place A Place B Place C Place D Done! Unfortunately, programming isn't always that kind. Sometimes the first position you choose for piece A makes it impossible to place D later. The mistake wasn't with D . The mistake happened much earlier. Enter Backtracking Backtracking works like this: Place a piece. Try placing the next one. If you get stuck... Remove the last piece. Try a different position. Repeat until every piece fits. It's essentially saying: "If this path doesn't work, let's go back and explore another one." Visualizing the Search Suppose we have four tetrominoes. Start ├── Put A at (0,0) │ ├── Put B │ │ ├── Put C │ │ │ ├── D fits ✅ │ │ │ └── D fails ❌ │ │ └── Try another position │ └── Move A elsewhere └── Try another position for A Every branch represents another possibility. Backtracking explores these branches until it finds one that works. How It Looks in Go The heart of the algorithm is surprisingly small. func solve ( index int ) bool { if index == len ( pieces ) { return true } for every
AI 资讯
JavaScript has no sorted containers. I built one for TypeScript.
JavaScript ships with Array , Set , and Map — but nothing that keeps its elements sorted as you insert. If you've ever built a leaderboard, an order book, or anything that answers "give me the items between X and Y", you know the workaround: push into an array and .sort() after every insertion. It works, until scale punishes you — you're paying O(n log n) over and over for data that was already 99.9% sorted. Python solved this years ago with sortedcontainers , built on an elegant "list of lists" design instead of balanced trees. I just published sorted-collections , which brings that idea to TypeScript — with full credit to the original as its inspiration. What you get SortedList, SortedSet, SortedMap — always sorted, no manual re-sorting, range queries built in. O(log n) insertions, O(√n) positional access via sqrt-decomposition into buckets. Zero runtime dependencies , ~2KB gzip, types included, dual ESM/CJS. Package quality gated in CI with publint , arethetypeswrong , and size-limit . The API in 30 seconds import { SortedList , SortedSet , SortedMap } from " sorted-collections " ; // SortedList: stays sorted on every insert const list = new SortedList ([ 5 , 1 , 4 , 2 , 3 ]); list . add ( 0 ); console . log ([... list ]); // [0, 1, 2, 3, 4, 5] console . log ( list . at ( 2 )); // 2 — positional access on sorted order // SortedSet: no duplicates, plus set algebra const a = new SortedSet ([ 1 , 2 , 3 , 4 ]); const b = new SortedSet ([ 3 , 4 , 5 ]); console . log ([... a . intersection ( b )]); // [3, 4] // SortedMap: keys always in order, range queries built in const prices = new SortedMap < number , string > ([ [ 104.5 , " order-3 " ], [ 99.2 , " order-1 " ], [ 101.0 , " order-2 " ], ]); for ( const [ price , id ] of prices . irange ( 100 , 105 )) { console . log ( price , id ); // 101.0 order-2, then 104.5 order-3 } Custom comparators are fully typed: number and string get natural ordering for free; for your own types, TypeScript requires a comparator at compile
AI 资讯
US military sent explosive drone boats into combat for the first time
US military’s drone boats struck an Iranian naval port as war heats up again.
AI 资讯
DeepMind CEO calls for an independent standards body to regulate frontier AI
DeepMind CEO Demis Hassabis is proposing an AI "standards body" modeled after FINRA, to test frontier models and develop best practices for their release.
AI 资讯
Philips Hue’s budget-friendly Essential starter kit has hit a new low price
Although most of Prime Day’s unusually good Philips Hue deals have ended, a few remain, and some, including the black Philips Hue Twilight Sleep and Wake-Up Light, are even cheaper. None, however, have fallen to a new all-time low price like Philips Hue’s Essential starter kit. Right now, you can buy a bundle containing four […]
开源项目
Plex is down
Plex services have been experiencing some major issues today, with multiple users reporting problems on Plex's forums and on Reddit. Many people use Plex as a way to stream shows and movies they host locally, but users are upset because today's problems are reportedly affecting their ability to do that. "Basically all Plex is down […]
AI 资讯
Nintendo’s Switch 2 bundle that includes a game is $50 off
Discounts on the Nintendo Switch 2 are rare, but they do happen on occasion. There’s one happening now, actually, on the company’s $499.99 console bundle that includes a digital game (Mario Kart World, Donkey Kong Bananza, or Pokémon Pokopia). Usually, the bundle saves you $20 or $30, depending on the game you choose, but for […]
AI 资讯
Meta accused of using biased AI targeting for mass layoffs
A group of 26 former Meta employees is suing the company over claims that it used AI tools to unfairly target workers on leave with layoffs, as reported earlier by Reuters. In the lawsuit, the employees allege Meta determined which workers to dismiss based on performance data collected by a "constellation" of internal AI tools, […]
AI 资讯
AI Spend Console by Rippling
Track your AI spend and connect it to business outcomes Discussion | Link
AI 资讯
How To Watch the 2026 FIFA World Cup Semifinals: France vs Spain
The end of the FIFA Men’s World Cup is nigh. Here’s how to watch the final games and the first ever World Cup halftime show.
科技前沿
California's MyFirstEV provides a $3,500 instant rebate to first-time buyers
The Fed dropped the ball, but California's new program will provide up to $3,500 in instant rebates to first-time EV buyers.
产品设计
Big Mike
Your favorite uncle who knows sports & bets, on iMessage Discussion | Link
产品设计
Sony delays its new PS5 fight stick
Sony is delaying the launch of its FlexStrike fight stick controller for PS5 and PC, which had been set to launch on August 6th, to an unspecified date in the future. The company blames the delayed launch on "unexpected production delays." The original planned launch of the FlexStrike would have lined up with the release […]
开发者
Nomad’s high-end phone accessories are up to 30 percent off
Premium phone accessory maker Nomad is celebrating its anniversary with discounts on its entire catalog of products. The sale will knocks off up to thirty percent off usual prices and will run through July 20th. We found some particularly good deals from the sale we’d like to draw your attention to. Its Leather Mag Wallet […]
AI 资讯
DeepSeek reportedly in talks to raise $1.5B, then IPO
DeepSeek, the Chinese large language model developer, is said to be preparing for a 2027 IPO debut as it also looks to raise around $1.5 billion in new funds at a $71 billion valuation.
AI 资讯
The OLED Xbox Ally X20 is so good, Asus will sell it solo
When I first told you about the "OLED Xbox Ally X of my dreams," I had to curb my enthusiasm a bit. That's partly because I hadn't yet tried the handheld myself, and partly because Asus was only planning to sell it bundled with a pair of expensive AR glasses! I'm happy to say both […]
创业投融资
An Apple Arcade version of Madden NFL 27 will arrive on August 7
EA's football sim series is making its debut on Apple Arcade.
开源项目
🔥 1c7 / chinese-independent-developer - 👩🏿💻👨🏾💻👩🏼💻👨🏽💻👩🏻💻中国独立开发者项目列表 -- 分享大家都在做什么
GitHub热门项目 | 👩🏿💻👨🏾💻👩🏼💻👨🏽💻👩🏻💻中国独立开发者项目列表 -- 分享大家都在做什么 | Stars: 52,940 | 1,194 stars today | 语言: Python
开发者
Your code reviewer should never be the first to read your code
the most useful habit i have hasn't changed in years: your reviewer should never be the first person to read your code. it doesn't matter if the change is one line. you read it first. the trick is reading it in the diff view, the same tool your reviewer will use, not your editor. the diff is a different lens. the debug print you forgot, the block you commented out, the variable you renamed everywhere but one place, all of it looks fine while you're writing and wrong sitting next to everything else that changed. this matters more now that an agent writes the code, not less. you're no longer the author who remembers every keystroke. you're the first reviewer of a change you mostly watched happen. so read it like a stranger wrote it. in a sense, one did. https://starikov.co/commit-lifecycle/ submitted by /u/iGotYourPistola [link] [留言]
AI 资讯
Google Images gets a Pinterest-like redesign focused on discovery
Now, when users navigate to Google Images, they'll see a "For You" gallery of images tailored to their interests and browsing history.