<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by naman surana on Medium]]></title>
        <description><![CDATA[Stories by naman surana on Medium]]></description>
        <link>https://medium.com/@nmn_?source=rss-b2fd304e0f1f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*K9KmxW59xuXySZqa9dhblg.jpeg</url>
            <title>Stories by naman surana on Medium</title>
            <link>https://medium.com/@nmn_?source=rss-b2fd304e0f1f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 14:47:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nmn_/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Who’s Actually the Best F1 Driver using ELO system?]]></title>
            <link>https://medium.com/@nmn_/whos-actually-the-best-f1-driver-ed9be84581b9?source=rss-b2fd304e0f1f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed9be84581b9</guid>
            <category><![CDATA[elo]]></category>
            <category><![CDATA[f1]]></category>
            <dc:creator><![CDATA[naman surana]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 18:43:44 GMT</pubDate>
            <atom:updated>2026-10-14T08:05:46.828Z</atom:updated>
            <content:encoded><![CDATA[<p>After watching Max Verstappen win back-to-back Grands Prix in dominant fashion, I thought, he should objectively be the best driver on the grid<em>.</em></p><p>Then I looked at the standings and saw him sitting <strong>119 points behind Kimi.</strong></p><p>That got me thinking: when the car plays such a massive role in a driver’s success, how do you separate the driver’s skill from the machinery? And more importantly, how do you figure out who’s truly the greatest across different eras of F1?</p><p><strong>So, I built an Elo rating system to cut through the machinery, the eras, and the hype, and rate F1 drivers based on their actual skill.</strong></p><h3>Content of this blog</h3><ol><li><a href="#524a">The Initial Idea</a></li><li><a href="#f9ad">Math: How does ELO work?</a></li><li><a href="#a847">Beyond Standard Elo</a></li></ol><ul><li><a href="#5b23">The Signal-to-Noise Ratio</a></li><li><a href="#4cf0">Empirical-Bayes Shrinkage</a></li><li><a href="#a3c8">Lifecycle Asymmetry &amp; Peak Isolation</a></li></ul><p>4. <a href="#2df0">Output: The All-Time Peak Leaderboard</a></p><p>5.<a href="#aa60">References &amp; Credits</a></p><h3><strong>The Initial Idea</strong></h3><p>The easiest way to tell if a driver is good is by looking at the standings declare who was better in the team. However this has a flaw. It does not account for drivers in other teams.</p><p>So the workaround is to find head to head battle between 2 drivers where the winners get placed above the losers of the particular team.</p><p>For example- in the 2024 f1 season, sergio perez finished 8th in the driver standings whereas alonso finished 9th. the gap between them was 82 points, however perez was -285 points (losing h2h 23 -1) behind his teammate whereas alonso was +46 points(winning h2h 17–7) ahead of his teammate. This means that alonso was better than perez? right? Yes, anyone who watched the season knows it is true, but it is not right way to reach this conclusion as while alonso’s teammate was a <strong>pay driver</strong> called lance stroll, perez’s teammate was MAX VERSTAPPEN! Funnily enough, when perez and stroll were teammates at racing point, perez lead the latter by 26 -11, so this analogy becomes ever more muddier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/0*lqmSMHs-Wb1KzsuG" /><figcaption>max vs stroll</figcaption></figure><p>The solution is to work in a chain of command , collect data and figure out how each driver pairs with every other driver with a confidence score.</p><p>Once I collected all the data, I cleaned it. It involved removing sessions where a driver retired due to a mechanical issue or crash. Next up, I removed single-car entries, unclassified results (DNS, DNQ, and post-race disqualifications), and 1950s shared-drive duplicates, keeping only sessions where both teammates were officially classified in equal machinery.</p><h3>Math: How does ELO work?</h3><p>Elo system relies on the <strong>expected </strong>probabilty of player A defeating player B. if player A has a 60 percent chance of beating player B, and it ends up happening then the delta gain for A is less if opposite were to occur as B was already the underdog. Initially every driver is given an ELO of <strong>1500 </strong>and from there based on the parameters mentioned the system updates.</p><h4><strong>1. Expected Outcome (E_A)</strong></h4><p>The model computes the probability that Driver A will beat Driver B based on the difference between their ratings before the race:</p><pre>E_A = 1 / (1 + 10^((R_B - R_A) / 400))</pre><p>If Driver A and Driver B are equal rated (say 1500), then E_A = 0.50, that is, a 50/50 chance. The 400 in the formula is a scaling constant- a 400 point lead means you are about 10 times more likely to win.</p><h4>2. Rating Update (ΔR)</h4><p>After the race, ratings change based on the actual result versus the expected result:</p><pre>R_A_new = R_A_old + K × (S_A − E_A)</pre><ul><li>1.0 if Driver A wins</li><li>0.5 for a tie</li><li>0.0 if Driver B wins</li></ul><p><strong>K is the sensitivity factor (K = 15):</strong><br>Low value of K ( 8) would penalize great drivers like hamilton from their elo rising , whereas high K(40) would paint a false outlook for performances like gasly monza 2020. I chose 15, cuz F1 has historically averaged around 15 races per season.</p><h3>Beyond Standard Elo:</h3><p>while the elo rating served as a great base , I still couldnt rely on a standard elo model due to it treating everyone equally.</p><h4>1. The Signal-to-Noise Ratio:</h4><ul><li><strong>Qualifying</strong> measures pure 1-lap driver pace over 5–6 kilometers of empty asphalt with zero traffic.</li><li><strong>The Grand Prix</strong> is subject to safety car timing, pit-stop cross-threads, tire degradation, and team strategy blunders.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*YF0acblrXfqryhnH.jpg" /><figcaption>Inframe: Ferrari’s strategy pitwall</figcaption></figure><p>We can model the observed lap time performance variance σ²_observed as: <strong>σ²_observed = σ²_driver + σ²_car + σ²_chaos</strong></p><p>In qualifying with equal machinery, σ²_chaos ≈ 0. In a race, σ²_chaos is massive. The updated session equation scales our Elo sensitivity by session weight:</p><pre>ΔR = K × W_session × (S_A − E_A)</pre><p>Where: W_session = 1.00 for Qualifying. W_session = 0.65 for Race</p><p>Basically, outqualifying your teammate gives you a better delta than finishing above them in race classification because races are more uncertain.</p><h4>2. Empirical-Bayes Shrinkage</h4><p>In order to avoid <strong>“Elo farming”</strong>, the empirical-Bayes shrinkage is applied before the update calculation. The effective opponent’s rating is shrunk toward the era’s baseline μ_era = 1500 based on the sample size N:</p><pre>R_effective = (N / (N + N_0)) × R_observed + (N_0 / (N + N_0)) × μ_era</pre><p>N is the number of classified sessions that the teammate played.</p><p>N_0 = 12 is the Bayesian prior strength (which corresponds to about half of a season).</p><p><strong>An Interesting Observation</strong></p><p>Let us consider two completely opposite teammate matches:</p><p>Max Verstappen vs. Sergio Pérez (2024): Head-to-head match 23–1 with 42-point Elo increase in my rating system.</p><p>Nico Rosberg vs. Lewis Hamilton (2016): Close head-to-head match 10–9 with 38-point Elo increase.</p><p>Despite the huge difference in the head-to-head statistics of those teammates, the resulting Elo increase was very similar. It proves that win counts do not affect ratings update. Expected outcome, opponent’s rating, session weight, and shrinkage factor all play role in the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/0*RIFb2OnULTqFGQyI" /><figcaption>Inframe: monaco based youtuber who beat lewis hamilton in equal machinery</figcaption></figure><h4>3. Lifecycle Asymmetry &amp; Peak Isolation</h4><p>Elo is basically a running version of the much older Bradley-Terry model: every driver has one hidden strength number, and the chance A beats B depends only on the gap between them. That’s exactly what E_A computes. Since it only needs pairs, drivers who never raced each other can still be compared through shared teammates. Hamilton and Schumacher never shared a team, but both were Rosberg’s teammates, and chains of these “bridge” drivers connect the eras.</p><p>The problem is <em>when</em> those bridges form. A lot of them happen when one driver is on his way out and the other is just arriving. Schumacher was 41 when he partnered a 25-year-old Rosberg in 2010–12, and plain Elo reads that as “this is how good they both are.” So the veteran gets punished for being past it, and the youngster gets credit he may not have earned.</p><p>So I added an age adjustment. Once a driver is past his prime, his rating gets discounted, slowly at first and then faster every year. A late-career loss no longer drags down what he was at his best, and beating him counts for a bit less. Before each expected result, the rating gets adjusted like this:</p><pre>R_effective(i, t) = R_peak(i) - α × max(0, Age(i, t) - Age_optimal)²</pre><p>Here, Age_optimal ≈ 28–32 represents the assumed peak-performance window, while α is the empirical post-prime decay coefficient. Teammate rating transfers are calibrated against R_effective, preserving the integrity of historical network bridges without penalizing a driver&#39;s estimated peak ability for continuing to compete beyond their prime.</p><h3>Output: The All-Time Peak Leaderboard</h3><p>and the best f1 driver of all time is → <strong>schumacher (narrowly)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*yJw-hI6PAKdUQU74Ux1EGQ.png" /></figure><p><strong>Schumacher </strong>tops the board, which is not too controversial considering how close <strong>Hamilton(1752) </strong>and especially<strong> Verstappen(1748) </strong>are. <strong>Senna </strong>is massively helped by my preference to weigh raw pace over race pace, but even with that, <strong>Prost </strong>is only 3 points behind him.</p><p>Even though Sebastian Vettel has won 4 world championships, has <strong>57 pole positions(4th all time)</strong>, and is a 53-time Grand Prix winner<strong>(4th here as well),</strong> he is still only 9th because he was a Newey merchant racing against an aging Mark Webber rather than an elite benchmark. His mathematical rating ceiling was permanently anchored by decisive intra-team defeats to Daniel Ricciardo (2014) and Charles Leclerc (2019–2020), and his narrow operating window suffered from lower adaptability and costly unforced errors once cars lost their planted rear downforce.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/0*6NDMqxzMMPLWfcEx" /><figcaption>Inframe: Vettel crashing and losing the 2018 F1 world title</figcaption></figure><p>Finally, the modern trio of <strong>Leclerc (1670), Norris (1664), and Russell (1658)</strong> is locked within a razor-thin 12-point cluster, proving that the real-world performance delta among today’s front-runners is almost entirely dictated by<strong> car development</strong> rather than individual driver ability.</p><h3><strong>References &amp; Credits:</strong></h3><ol><li><strong>Marcel Overdijk- </strong><a href="https://github.com/marceloverdijk/f1db">F1DB (Formula 1 Database)</a></li><li><strong>Dr. Andrew Phillips- </strong><a href="https://f1metrics.wordpress.com/2019/11/22/the-f1metrics-top-100"><strong>f1metrics: A Mathematical Model to Measure Driver Performance</strong></a><strong> </strong>(the best article on this subject matter)</li><li><strong>Chris Hermansen- </strong><a href="http://ergast.com/mrd/">The Ergast Developer API</a></li><li><strong>Arpad Elo (1978)- </strong><em>The Rating of Chessplayers, Past and Present</em> (Arco Publishing)</li><li><strong>Ralph A. Bradley &amp; Milton E. Terry (1952)- </strong><em>Rank Analysis of Incomplete Block Designs: I. The Method of Paired Comparisons</em>, <em>Biometrika</em>, 39(3/4), 324–345.</li><li><strong>FiveThirtyEight-</strong>Nate Silver &amp; Team</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed9be84581b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Rubik’s Cube Solver in C++ with Thistlethwaite’s Algorithm]]></title>
            <link>https://medium.com/@nmn_/building-a-rubiks-cube-solver-in-c-with-thistlethwaite-s-algorithm-20a1121e07d9?source=rss-b2fd304e0f1f------2</link>
            <guid isPermaLink="false">https://medium.com/p/20a1121e07d9</guid>
            <dc:creator><![CDATA[naman surana]]></dc:creator>
            <pubDate>Sat, 06 Jun 2026 10:22:42 GMT</pubDate>
            <atom:updated>2026-10-12T12:58:23.846Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>During my 6th semester of engineering, I was introduced to search algorithms in my Artificial Intelligence subject. While going through the course material, Rubik’s Cube was briefly mentioned as a classic example of a problem with an enormous search space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*TkWyQUU597g3y89uC-8dyA.jpeg" /><figcaption>3x3 Rubik’s Cube</figcaption></figure><p>As someone who has spent some time speedcubing, researching on this topic led me down a rabbit hole of cube notation, state representation, group theory, BFS, DFS, pruning tables.</p><p>While standard algorithms like CFOP, Roux and ZZ are suited for human speedcubing approach and Korf, Kociemba are suited for computers, Thistlethwaite stands in the middle of these two approaches. Thistlethwaite’s method differs from layer-by-layer and corners-first approaches because it does not solve individual pieces one at a time. Instead, it treats the cube as a whole, progressively restricting the possible positions and orientations of all pieces until each piece has only one valid location and the cube is solved.</p><p>The method achieves this by first transforming the cube into a state that can be solved without quarter turns of the <strong>U</strong> and <strong>D</strong> faces, while still allowing their half turns. It then continues solving under this restriction, reaching a state where quarter turns of the <strong>F</strong> and <strong>B</strong> faces are also unnecessary. As additional move restrictions are introduced, the cube eventually reaches a configuration that requires no <strong>quarter</strong> turns at all and can be solved entirely using <strong>half turns</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*8qUkzsr9uV57H4ur-CUdag.jpeg" /><figcaption>Each phase and their total possible combinations</figcaption></figure><p>The implementation was developed in C++ due to its efficient memory usage, low-level control over data structures, and high execution speed, all of which are crucial for solving a Rubik’s Cube efficiently. At its core, the solver relies on a combination of <strong>Breadth-First Search (BFS) </strong>and <strong>Iterative Deepening Depth-First Search (IDDFS)</strong>. BFS is used during preprocessing to generate pruning tables and compute minimum distances within each subgroup, enabling the solver to quickly estimate how far a given state is from the target subgroup. These pruning tables significantly reduce the search space by eliminating moves that cannot lead to an optimal solution. IDDFS is then employed during the four phases of Thistlethwaite’s algorithm to systematically explore possible move sequences while maintaining low memory consumption. By combining the optimal distance information provided by BFS-generated tables with the depth-limited exploration of IDDFS, the solver can efficiently navigate the vast state space of the Rubik’s Cube and progressively transform any scrambled configuration into the solved state.</p><pre>+--------------------+<br>|  Scrambled Cube    |<br>+--------------------+<br>          |<br>          v<br>+--------------------+<br>|  Phase 1           |<br>|  Edge Orientation  |<br>+--------------------+<br>          |<br>          v<br>+--------------------+<br>|  Phase 2           |<br>|  Corner Orientation|<br>|  + Slice Edges     |<br>+--------------------+<br>          |<br>          v<br>+--------------------+<br>|  Phase 3           |<br>| Permutation        |<br>| Reduction          |<br>+--------------------+<br>          |<br>          v<br>+--------------------+<br>|  Phase 4           |<br>|  Final Solve       |<br>+--------------------+<br>          |<br>          v<br>+--------------------+<br>| Solution Sequence  |<br>+--------------------+<br>          |<br>          v<br>+--------------------+<br>|   Solved Cube      |<br>+--------------------+</pre><p>My initial solver took around 8 minutes to find a solution, which was honestly painful to sit through. Hash tables and precomputed pruning tables brought it down to ~10 seconds (lowkey still mid), but the memory usage and CPU load were getting out of hand.</p><p>I started digging into how the solver handled memory and realized there was plenty of room for improvement. I switched to precomputed BFS pruning tables stored in .bin files, loaded directly into contiguous memory buffers. I also packed cube states using bitwise operations, ternary corner orientations, and Lehmer codes to make lookups faster and more memory-efficient.</p><p>The search needed work too, so I implemented IDA* with heuristic-based move ordering, axis pruning, and transposition tables to avoid wasting time exploring redundant paths. Phase 3 was easily the most frustrating part, with its restricted moves, parity constraints, and enormous search space.</p><p>As someone who enjoys speedcubing, building a Thistlethwaite solver was a different kind of challenge. Instead of solving a cube through algorithms and muscle memory, I was breaking the puzzle down mathematically and figuring out how to make the computer solve it efficiently. This could be further optimised, specially by using more modern day algos, but that is for another day.</p><p>Feel free to clone the attached repo and check the results for yourself. Any contributions to the project are welcomed.</p><p>The backend is hosted on a free Render instance with a cron job, so the initial spin-up might take a second.</p><ul><li><a href="https://github.com/nmncodes/CubeVault">GitHub - nmncodes/CubeVault</a></li><li><a href="https://cubevault.vercel.app/">CubeVault</a></li></ul><p><em>Sources from which I took inspiration to write this article-&gt;</em></p><p><a href="https://www.jaapsch.net/puzzles/thistle.htm">Thistlethwaite&#39;s 52-move algorithm</a></p><p>https://iscara.medium.com/common-rubiks-cube-algorithms-for-machines-part-1-of-2-in-a-quest-to-understand-the-rubik-s-cube-3cb9b53f94b5</p><p><a href="https://www.speedsolving.com/wiki/index.php/Human_Thistlethwaite_Algorithm">Human Thistlethwaite Algorithm</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20a1121e07d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Musings on Leetcode]]></title>
            <link>https://medium.com/@nmn_/musings-on-leetcode-ee176449cd95?source=rss-b2fd304e0f1f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee176449cd95</guid>
            <category><![CDATA[musings]]></category>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[hiring]]></category>
            <dc:creator><![CDATA[naman surana]]></dc:creator>
            <pubDate>Wed, 01 Oct 2025 20:31:00 GMT</pubDate>
            <atom:updated>2025-10-01T20:31:00.122Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s 1 AM on some random wednesday, and you’re staring at a problem like <em>“</em><a href="https://leetcode.com/problems/minimum-cost-to-cut-a-stick/">Minimum Cost to Cut a Stick</a><em>”</em>, wondering how this actually helps the world more than a doctor saving lives or a mechanic repairing your car.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*T9yiyZeEsDdJO1QiJGmvvA.png" /></figure><p>Linkedin influencers(dumbasses) are posting “12 leetcode patterns to crack FAANG” like memorizing them will get you a personal call from sundar pichai. Your submission graph looks nice and green, built mostly by copying code from ChatGPT. (Lets be real, anyone with an acceptance rate over 50-60% is either cheating or avoiding the real questions on tougher topics.)</p><p>So why bother? why learn DP, bitmasks, trees, and all those patterns when we can use that time to build real software? Maybe it’s because problem solving skills matter, maybe because being able to approach a problem logically actually saves time and effort. Its not just about the money, it’s about the genuine interest in optimizing and improving a piece of code, even if this space has been polluted with courses and sheets.</p><p>Is leetcode the only way to achieve this? IDK? Maybe not.</p><p>The real issue is when hiring turns into a strict 0/1 system: if you can’t solve an alice/bob puzzle, you’re suddenly “not good enough” for some XYZ american MNC. Or when you are supposed to solve an advanced ds question in an OA round within 20 mins. Like wtf? does it not become then about who can cheat the fastest?</p><p>The reality is that, leetcode no matter how frustrating it might be, is possibly the most meritocratic way to weed out candidates(not select them) but to eliminate the ones that couldnt give enough efforts to prepare themselves for this slugfest. Else how would you select someone? Their grades? Someone with a 9.5 gpa is surely a hardworking fella, but its relevance to the actual job posting still feels hazy. Their university? <em>“If you fuck up at the tender age of 18, then you shall never be granted a place within mine company.” </em>Real dystopian shit like its in china or south korea. Or judge them for the work they would actually do in the company? Well that looks rosy but when 5000 candidates are knocking on your door, even this becomes a far-fetched idea.</p><p>The reality is the mixture of all this. Everything matters, and nothing does. It all depends on what your calling card is.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee176449cd95" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>