Uploads from Xah Lee

Watch and track your favorite playlist.

Curated by: Xah Lee (862 videos)


Currently Playing: Xah Ep736 Wolfram Language, Advent of Code 2025, Day 6

Video Summary (Generated by AI, Edited by Human.) • Introduction to Advent of Code and Wolfram Language (0:08-3:51). • Discuss the typical time it takes to solve Advent of Code problems, noting that later problems can take several hours or days (1:00-1:27). • On "speed coders" who solve problems extremely fast, sometimes in a minute, and the removal of the global leaderboard due to abuse (1:44-2:40). • for those new to Wolfram Language, watch talk show episode (3:04-3:27) and a tutorial on his website (3:31-3:43), and download link for the Wolfram Engine (3:44-3:52). • Problem Description: Day 6, Problem 1 (6:19-12:12). • The input is a list of problems arranged vertically, where each problem consists of numbers and an operation symbol (+ or *) at the bottom. • Problems are separated by columns of spaces. • The goal is to calculate the sum of all individual problem answers to find the "grand total.". On using matrix transposition (11:23-12:02). • Initial Approach (12:20-33:00): • Starts by preparing the input data, converting the raw text into a matrix of strings (13:49-21:13). • special handle of the last row, which contains operation symbols. • Separates the operation list from the number matrix (24:44-25:56). • Core solution involves transposing the number matrix and converting its elements to numbers (25:57-26:02). • Use MapThread to apply the correct operation (sum or product) to each row of numbers based on the corresponding operator (27:56-32:00). • Debugging and Solution (35:10-43:05): The initial solution yields an incorrect grand total (35:28). • Debug. Checking intermediate results (39:03-40:07) and realizing that a simple syntax error in his conditional logic was causing the issue (42:33-42:40). • The correct solution is obtained (42:50-43:05). • Refining and Shortening the Code (46:24-1:19:00). Compacting the code into a "one-line" solution (46:24-1:19:00). • This involves: • Use string replacement to change '+' and '*' characters to Wolfram Language's Plus and Times symbols (1:00:59-1:01:11, 1:14:53-1:15:04). • Leveraging RotateRight to move the operator row to the beginning (1:15:18-1:15:26). • Apply ToExpression to convert all strings in the matrix to expressions (numbers and function symbols) (1:15:28-1:15:33). • Use Transpose to align operators with their respective number lists (1:15:37-1:15:53). • Finally, use Map with Apply to perform the operation (first element) on the rest of the elements in each row (1:15:54-1:16:10), followed by Total to sum the results (1:16:13-1:16:15). • Claim that this compact Wolfram Language solution is likely the shortest possible in any programming language by token count (1:16:21-1:17:14). Notes at http://xahlee.info/talk_show/xah_talk_show_ep736.html If browser says security error, that is because it auto changes URL from HTTP to HTTPS. It's a way to censor 22 million old websites. Remove the S in HTTPS. Or use brave browser or safari.


Tracks in this Playlist