今日已更新 166 条资讯 | 累计 20138 条内容
关于我们

今日精选

HOT

最新资讯

共 20138 篇
第 22/1007 页
AI 资讯 Dev.to

# 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

Ouma Asoyoh 2026-07-15 02:22 2 原文
AI 资讯 Dev.to

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

Johans Neira 2026-07-15 02:21 2 原文
开源项目 The Verge AI

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 […]

Jay Peters 2026-07-15 01:23 5 原文
AI 资讯 The Verge 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 […]

Cameron Faulkner 2026-07-15 01:20 2 原文
AI 资讯 The Verge 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, […]

Emma Roth 2026-07-15 01:18 2 原文
产品设计 Product Hunt

Jam-Pod

A player for people who keep their own music collection Discussion | Link

Gianpaolo Campoli 2026-07-15 01:08 2 原文