<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>

		<title>ris8z</title>
		<link>https://ris8z.com/</link>
		<description>ris8z’s weblog.</description>
		<language>en-us</language>
		<atom:link href="https://ris8z.com/feed.xml" rel="self" type="application/rss+xml" />

			
			
			<item>
			<title>Ris8z | CP leetcode strategy</title>
			<pubDate>Tue, 02 Jun 2026 14:16:40 GMT</pubDate>
			<guid isPermaLink="false">BB90065D-BA59-451A-86BE-E699D9A80A33</guid>
			<link>https://ris8z.com/posts/CP-leetcode-strategy.html</link>
			<description><![CDATA[
<h1> CP leetcode strategy </h1>
        <h4> Context </h4>

            <p>
                A month ago I went to a programming competition in Cork, very fun, but very difficult for me,
                my only experience with that kind of problem solving, was only through leetcode, 
                I'm not even that bad at leetcode. To go straight to the point I found it very intresting and I
                want to imporve (yes probably it is useless) but it seems to me like a fun game. 
            </p>

            <p> 
                I started to do some training on <a href="https://open.kattis.com/">kattis website</a>, 
                is not as serius as <a href="https://codeforces.com/">code force</a> but is still something (and I like the cat), but I felt like I was just spending too
                much time tring to come up with a pattern that maybe I just needed to have studied before, 
                so I did the most inteligent thing to do and I asked my Friend LLM (BIG BOSS Gemini) 
                for an algorithmic strategy to apply every time i try to solve a problem. 
            </p>

        <h4> Strategy </h4>
        
            <p>
                -1) Don't waste your effort: keep track of your work:
                <ul>   
                    <li>I keep track of my solution and pattern used inside a google sheet.</li>
                    <li>This is my <a href="https://docs.google.com/spreadsheets/d/1XsQn0q-1qMcJJMFDPgw5ADIZRW6YVxq_W4VwoToYURU/edit?usp=sharing">google sheet</a> as example.</li>
                    <li>I think the most important colum is the Note setcion: where I bully myself when i do some silly errors.</li>
                </ul>

                0) Time constrantis (1hr):
                <ul>   
                    <li>30 min max to think about a valid approach.</li>
                    <li>10 min max to write the code solution.</li>
                    <li>20 min left ask LLM for a solution (if you did not find it) or for a better solution.</li>
                </ul>

                1) Stroy vs Logic
                <ul>   
                    <li>Ignore the story (just skim through it).</li>
                    <li>Try to understand as fast as possible which is the key question i.e. (is a graph question? is it a array question? etc...).</li>
                    <li>For god sake read really good the output section to understand how to parse the input (i.e. how many test case are etc...) and what you need to output for each one.</li>
                </ul>

                2) Check the limit of N to understand which apporch suits better
                <ul>   
                    <li>The time limit on kattis is usually 1 cpu second but you can check it for each task in the section metadata.</li>
                    <li>I'm using python because this is a game for me, if you are using C++ you are probably a tryharder and this is not the right article for you.</li>
                    <li>According to my LLM of trust python3 can do between 10 million or 20 million operation per sec.</li>
                    <li>That is an interval that looks like this: [10^7,2*10^7].</li>
                    <li>We can use this information to get for each time complexity the max number of input size computable into a CPU second.</li>
                    <li>If you want to read out the maths it is in the last section of this post but I will summurazie the info in a simple table here:</li>
                </ul>

                <table border="1" cellpadding="10" cellspacing="0" width="100%">
                    <thead>
                        <tr>
                            <th>Calculated Max Size of \( N \)</th>
                            <th>Accepted Complexity</th>
                            <th>Likely Algorithms</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>\( N \le 10 \)</td>
                            <td>\( O(N!) \)</td>
                            <td>Extreme brute force, Permutations (e.g., Traveling Salesperson).</td>
                        </tr>
                        <tr>
                            <td>\( N \le 20 \dots 23 \)</td>
                            <td>\( O(2^N) \)</td>
                            <td>Backtracking, Searching all subsets (e.g., Subset Sum).</td>
                        </tr>
                        <tr>
                            <td>\( N \le 200 \dots 500 \)</td>
                            <td>\( O(N^3) \)</td>
                            <td>3-state Dynamic Programming (DP), Dense graphs (Floyd-Warshall).</td>
                        </tr>
                        <tr>
                            <td>\( N \le 3000 \dots 5000 \)</td>
                            <td>\( O(N^2) \)</td>
                            <td>Nested <code>for</code> loops, Basic DP (e.g., Longest Common Subsequence).</td>
                        </tr>
                        <tr>
                            <td>\( N \le 10^5 \dots 5 \times 10^5 \)</td>
                            <td>\( O(N \log N) \)</td>
                            <td><strong>90% of problems.</strong> Sorting, Heaps, Advanced Binary Search, Dijkstra.</td>
                        </tr>
                        <tr>
                            <td>\( N \le 10^6 \dots 10^7 \)</td>
                            <td>\( O(N) \)</td>
                            <td>Two Pointers, Greedy algorithms, BFS/DFS, Hash Maps, Linear Arrays.</td>
                        </tr>
                        <tr>
                            <td>\( N \ge 10^9 \)</td>
                            <td>\( O(\log N) \) or \( O(1) \)</td>
                            <td>Pure math formulas, Binary Search on the answer space. You cannot use arrays of this size!</td>
                        </tr>
                    </tbody>
                </table>

                <br>

                3) Analyze Edge cases 
                <ul>   
                    <li>Once we have an idea on the algorithm to use we need to ask ourself were it could break?:</li>
                    <li>What happens if N = 0 or N = 1?</li>
                    <li>Is there any negative number (i.e. if yes Dijkstra doesn't work)</li>
                    <li>What happens if are the elmenet are the same</li>
                    <li>Can the graph be discontected? etc...</li>
                </ul>


                4) Mock run on the Test case 
                <ul>   
                    <li>Never start to code before solving the Test case on the whiteboard.</li>
                    <li>If the input example is too easy try to think of a better one that can include also edge cases.</li>
                    <li>Some times completing the test case is very time consiuming (i.e. fulltank on kattis) if it is the case once you have to main understading go for it.</li>
                </ul>
            </p>

            <p>

            
        <h4> Math in details for time complexity and input size limits </h4>
            <p>
                Each time complexity is the number of operation our alogrithm does with an input of size N, so we need to lock that to be less then or equal to 
                10^7 (the number of operation that python does into a CPU second) then solve di disequation to get the range of input size of which our alogithm can run in just a CPU second,
                the last value is the max input size acceptable.
            </p>

            <div>
                \(
                \displaystyle
                \begin{aligned}
                (1) \quad &\mathcal{O}(\log N) \implies \log_2 N \le 10^7 \iff N \le 2^{10^7} \implies N_{\max} \to \infty \\
                \\
                (2) \quad &\mathcal{O}(N) \implies N \le 10^7 \implies N_{\max} = 10^7 \\
                \\
                (3) \quad &\mathcal{O}(N \log N) \implies N \log_2 N \le 10^7 \implies 10^5 \cdot \log_2(10^5) \approx 1.66 \cdot 10^6 \le 10^7 \implies N_{\max} \approx 10^5 \\
                \\
                (4) \quad &\mathcal{O}(N^2) \implies N^2 \le 10^7 \iff N \le \sqrt{10^7} = 10^{3.5} \approx 3162 \implies N_{\max} \approx 3000 \\
                \\
                (5) \quad &\mathcal{O}(N^3) \implies N^3 \le 10^7 \iff N \le \sqrt[3]{10^7} = 10^{\frac{7}{3}} \approx 215 \implies N_{\max} \approx 200 \\
                \\
                (6) \quad &\mathcal{O}(2^N) \implies 2^N \le 10^7 \iff N \le \log_2(10^7) = 7 \log_2(10) \approx 23.2 \implies N_{\max} \approx 23 \\
                \\
                (7) \quad &\mathcal{O}(N!) \implies N! \le 10^7 \iff \begin{cases} 10! \approx 3.6 \cdot 10^6 \le 10^7 \\ 11! \approx 3.9 \cdot 10^7 > 10^7 \end{cases} \implies N_{\max} = 10
                \end{aligned}
                \)
            </div>

            <p> 
                You may notice that the limits in the table are a bit larger that because a lot of the times for example an N^3 algorithm dosen't actually run 
                3 full cylce but a bit less in each cycle. (DEPENDS ON THE ALGORITHM IMPLEMENTATION).
            </p>

        <h4> Thanks to </h4>
            <p>
                Gemini for the big cool table and latex code. 
            </p>
            <p>
                PS: I did not make it review my grammar so this post grammar is going to be shit but it's late and it's my website so I do whatever i want :)
            </p>
			]]></description>
		</item>

		<item>
			<title>Ris8z | Why this blog?</title>
			<pubDate>Tue, 03 Feb 2026 02:54:41 GMT</pubDate>
			<guid isPermaLink="false">5BE13656-342A-4C2C-9966-DDA87DB57C7A</guid>
			<link>https://ris8z.com/posts/why-this-blog.html</link>
			<description><![CDATA[
<h1>Why this blog?</h1>
        
        <p>
            Okay, a bit of an introduction: I'm just a guy in his last year of a Computer Science Bachelor's degree.
            In some sense, I feel lost, but I shouldn't be. I have good grades, I had the opportunity to find an internship,
            and even got a return offer. While everyone is complaining about how bad the job market is for CS students, I think I've had a lot of luck
            and things sorted out for me.
        </p>
        
        <p>
            That is not the main point of this article. The point is: I've always loved computer science (or whatever was related to computers) since I was a child.
            I'm from Italy, so I couldn't do any computer science at high school. I decided to just learn C on my own. It was fun and I had a very good time.
            I remember being in D&D sessions with my friends on Discord (because of COVID-19) while trying to understand pointers and matrices.
        </p>
        
        <p>
            After that, I finally had the opportunity to study Computer Science at university. I'm very lucky because my sister went to a university in the UK, so I had
            the opportunity of doing my university in Dublin. Let's forget the context (like how it was living in Dublin alone, rent problems, flatmate problems, etc).
            First semester I was having a really good time with the Python course as an introduction to computing (a bit odd for me, having started with the "Italian approach" from C),
            but after 2 or 3 weeks I got comfortable with Python. Every week I was just devouring more and more exercises. It was like a game: developing was, and is, really fun.
        </p>
        
        <p>
            Fast forward to the second semester: I was studying networks, having a bit of difficulty, and found out ChatGPT was out. Let me try it. It was amazing. Like, not "mind-blowing" amazing,
            but amazing compared to my expectations. So from then on, ChatGPT (or AI in general) started to be a really good friend of mine in this university journey.
        </p>
        
        <p>
            So, what the fuck is the problem? Not really any "problem," just the fact that I have used a lot of AI and I maybe missed some core aspects (by excusing it with abstraction).
            I really want to take it slow, go over all these topics, and learn little by little, maybe by writing a post about it. If I didn't understand it, maybe someone else didn't either,
            and I can help someone who wants to know.
        </p>
        
        <p>
            The dichotomy problem I was thinking about the last 3 or 4 weeks was essentially this: now that I'm in a world that moves really fast with AI and everyone is pushing that it will be the future
            (and I think it is the case), why should I lose time studying topics "better" that AI can ace for me? Like, I'm a pretty rational person; from my average point of view, it is not a good
            investment (i.e., 2 weeks ago I got curious how Floating Point number calculation worked. I spent 2h reading about it. Was it useful? Nah. Will I use it in the future? Nah. Did I like it? Yes,
            a lot. I think just because I'm a curious person). With this blog, I would like to share this and fill in all my gaps in knowledge.
        </p>
        
        <p>
            The main downside is a bit of FOMO (Fear Of Missing Out) about AI. Like, this thing is time-consuming. Yes, I do use AI almost every day, but not as much as I can see on X
            or YouTube. Like, I still haven't tried the agentic part. I will, and I think it is going to be amazing. I will use it to make some side projects, but at least now that I'm still
            in university and I don't need to be as "productive" as possible, I will take it slow and learn some curious concepts at the cost of being a bit behind on which is the best agent,
            or which is the best way to do prompt engineering, etc.
        </p>
        
        <p>
            Sorry for my bad writing, it's not my cup of tea, I know.
            You know I'll definitely use AI to fix it :).
        </p>
        
        <p>
            This is not some kind of article against AI. In fact, I use it every day and I love it. But this blog is going to be my little corner where I prioritize knowledge against
            fast productivity. Basically an excuse to take time to fulfill my curiosity on how things work.
        </p>
        
        <p>
            Philosophy of the blog?
            KISS: Keep It Simple, Stupid.
            If something is too complex to KISS, we try and get a less complex version of it to study.
        </p>

        <p>
            Thanks to Louie Mantia for his fantastic <a href="https://lmnt.me/blog/how-to-make-a-damn-website.html">blog post about creating a website.</a>
            <br>
            Thanks to Hello World! for his <a href="https://www.youtube.com/watch?v=vpuotuKkbEU&list=PLMtyAydbuhajKYtxQZB1dWAW0O4k1fTBH">C playlist</a>, which made me fall in love with programming during high school.
            <br>
            Thanks to Antirez and <a href="https://www.youtube.com/@antirez">his Italian YouTube channel</a>, which made me reflect on all those details I was missing about the subject I love.
            <br><br>
            Antirez once said that an expert stranded on a desert island should be able to rebuild their entire infrastructure from the ground up. So, maybe the next post will be on understanding how to build a very small (and probably bad) CPU. I might start with a high-level design and then go deeper. I only have a basic grasp of it right now, so I will read up on it and write as I learn.
        </p>
			]]></description>
		</item>
	</channel>
</rss>
