<?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 Prathamesh Nemade on Medium]]></title>
        <description><![CDATA[Stories by Prathamesh Nemade on Medium]]></description>
        <link>https://medium.com/@prathameshnemade?source=rss-928b2b53ae84------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*n5YmNpBIF4SfYpvh.jpg</url>
            <title>Stories by Prathamesh Nemade on Medium</title>
            <link>https://medium.com/@prathameshnemade?source=rss-928b2b53ae84------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 19:27:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prathameshnemade/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[Selection Sort using TypeScript!]]></title>
            <link>https://prathameshnemade.medium.com/selection-sort-using-typescript-f9cbf6729bdb?source=rss-928b2b53ae84------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9cbf6729bdb</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[interfaces]]></category>
            <dc:creator><![CDATA[Prathamesh Nemade]]></dc:creator>
            <pubDate>Tue, 26 Jul 2022 16:18:28 GMT</pubDate>
            <atom:updated>2022-07-26T16:22:52.160Z</atom:updated>
            <content:encoded><![CDATA[<p>Seems strange? Of course, folks.</p><p>I’ve recently learned that TypeScript can do more than just declare interfaces, enums, and the like. I am grateful to <a href="https://medium.com/u/276718f3621a"><strong>Matt Pocock</strong></a> for creating the <strong>TypeScript YouTube tutorials</strong> and series. I was able to easily understand the advanced TypeScript ideas, thanks to this tutorial.</p><p>Gist: Developing Selection sort is made feasible with the right use of TypeScript <strong>generics</strong>, <strong>infer</strong>, <strong>extends</strong>, and many more additional assets.</p><p>While creating this selection sort, I made an effort to compare it to or make it resemble a straightforward [O(n²)] JS Selection sort algorithm.</p><p>Following is a code snippet of <strong>Selection Sort algorithm with O(n²)</strong> complexity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kJnKSsLwOSzuET1hLamh4w.png" /><figcaption>Selection sort JS algorithm — O(n²)</figcaption></figure><p>With the exception of the element swapping, I was able to translate this into TypeScript. Once the smaller of two is identified, I did slice my array rather than swap.</p><p>Eg. const array = [2,1,5,0],<br>is array[0] &gt; array[1], if yes, push the smallest one in a different so called sorted array. And for the next iteration revamp the comparing array.<br>Therefore, after first iteration in this case, the resultant array left to sort is, [2,5,0] and the sorted array for next iteration(after iterating this for array.length times) would be [1,2,0,5].</p><p>I also made a comparator that will subtract both numbers and work appropriately for comparing two indexes (first and second).</p><p>Below is the<strong> type interface of the Comparator </strong>which uses the <strong>Subtract</strong> <strong>type</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xbEGKKoqZNT4bbaTObCfVQ.png" /><figcaption>Comparator and Subtract type interface</figcaption></figure><p>The Selection sort interface consumes the following arguments,<br>T — Input array which is extends/typeof number[]<br>C — Current iteration state of elements, to check if the iteration is done for all array elements<br>A — Total iterations state, should be equal to the length of input array to output the sorted array.<br>B — In current iteration, stores the elements remaining to be compared<br>M — In current iteration, stores the small elements accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oAdUvKi3Em9WQiA_qs_6aQ.png" /><figcaption>SelectionSort type interface</figcaption></figure><h3>Recursive type, DAMN!! 🤯</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XO_VRQcoPnLR2-a2" /><figcaption>Photo by <a href="https://unsplash.com/@javaistan?utm_source=medium&amp;utm_medium=referral">Afif Kusuma</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UlPamugUNYiwsHzz3_EP3Q.png" /><figcaption>Selection sort example</figcaption></figure><p><strong>TypeScript playground</strong> — <a href="https://www.typescriptlang.org/play?#code/HYQwtgpgzgDiDGEAEBhArlALgezAQQCcCQBPJAbwCgkakIAPGbAzJTEmZQ4klAiEJggAeACoAaJAHk69IcAAmUJCGAkA2gF0kAXiRaAfLqSjZ8pdPUAiADYRgAc0wALK9oD80pAC4k3UnwCQmKS6gB0EVKSqiSaBgDc1LQMTCxsHFxEpAAy9k7OYkZ6pgzmyjFaSJ6i1naOLm4+SMAQAG4QBIm0sqms7Jx+WSQAChgFEkgAokUmZvYWFR76EWETk9q+Le2dSTQpzH0ZgzwAYgCWBFiTdpDAmIXGJXLz5WqV1XOKyupnwABmHSQJ0kK1+AIISAAStBMEsTk0toDNm0OokAL6USj9ZDoLC4ADKaAARphiPB7hMAKozXE4fBDML+Xj8QQiURGUovZYRMGA-EgiK03BMxlDQKs4TUpb42p5BobZoonbY1C4ODEHAEEJIanGIVgQkkskUyS6zlfRXbKpIP4gGxQZC+UloCCJSgAegAVJ7qJ6kPiIHZyWdsMB-QdfbMALRIACSwBgaFYICGkZQSBj6CI9lYZyEGpDYawrMjeAzJmwmDtSDzHUEheUxaEkYAQuWW3bVIg6Dcc+X+GAQL9fg42NgkETkFADhAFJGALLl-EzhRIJvIbB-HsQW6YZS-JDwNDZu5rqvNpCe90e90mcQocR4cQt8TzrFHANBzCF5csMSfCwWQUUMbDIYA0DAScCC0SR03NCxwMgjpKj0GC-AA5REKglD9E0SQ23gzCIOw7RUJWUQ8KQRdCOaYjkNI3Cil2PxZXqVxtBompbDldjrXdW8zi3HAqxsGt83rUMa2UCAAEc0GrHBaKQiFN23Xd9zDX5E2TVNujbXx+KQbAk205iUFY-JGk4iz5T4gStyPE9c3E79Q33aS5IU8csMBVTAx3HMNJrBMkxUXTaE-CBg1DX8TVw0IYgFRlKJfRimkMncYHYQ9j34U9VFXEAFFXX54BZB01zOAAvDchMratawLUN3RTHhmII54LR+f5AUmABGDClKgyReQhSYACZBp8ggktGqEYSmujoM0JZDMUgFMHgZwbQuLBJAdeBQ1Xfz1LMtUU0EZhhH6yQJo5TqLGdZBPEMraooAaxrLc-l21gTr7M5lAcFl8zYZxVDXKKjuYyLouAWLtXURKkBWFBKKffQbpRiJoSwSjwgiedbvGuJ0tvH7Lj+3tT0BpBgaCQEXAhg6jvLIrVxZxQ1IBosVzCtrulh1z4YORHkdR9HQgmpLcdhUIViJqY+tJgzb0546bhaXMgZBxnnHsHbKbZ4rDawbmad5lhZ350gYf8uGEYmJG1CStHJAxgmwkVlt1AABhW0I4niJBDMEyHDq5-6acwyskBgfgHTuFqhkqmqpKMlpyxcA2ACsMGTE3s6QTEb0mehwBgOwoHfAZWpyHiy4ruw9Xz4UGSZXI2OEdQAHIQB7yQe6JAekB7+Ae6DmvkDrkYxkbsBK+QPR9RFJlRigApe-7wfh8osee4SKebZIc5KeuAK7nnxeW7xekeFFU5fvP3du77keh-f8fJ6P6aoENUkECYCvs3ZercDTEgAeSYQAAWSQfVD4qkOgvC6mpgFL1VMgjUV1YFIHgW6FUDovw-gOGg4wQtiF-nUH1X2kgADMkgACskhxrMNYUgGhuC4hAA">link</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9cbf6729bdb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tic-tac-toe: MENACE v/s Human]]></title>
            <link>https://prathameshnemade.medium.com/tic-tac-toe-menace-v-s-human-f37750f8233b?source=rss-928b2b53ae84------2</link>
            <guid isPermaLink="false">https://medium.com/p/f37750f8233b</guid>
            <category><![CDATA[menaces]]></category>
            <category><![CDATA[tic-tac-toe]]></category>
            <dc:creator><![CDATA[Prathamesh Nemade]]></dc:creator>
            <pubDate>Tue, 24 May 2022 23:20:40 GMT</pubDate>
            <atom:updated>2022-05-24T23:22:11.523Z</atom:updated>
            <content:encoded><![CDATA[<p>To develop a MENACE machine that excels in the game of tic-tac-toe. The hashtables of a machine are modeled and trained by playing “n” games against a human/optimal strategy.<br>Based on the results of the games, make improvements to a model.</p><p><strong>MENACE</strong>: <br>Creating states for the MENACE machine, as well as providing the same number of initial beats to each of the playable places.<br>Considering that MENACE is the initial player, after every even move, hunt for the state in the HashTable and pick up the empty state using randomly weighted logic.<br>By rewarding and subtracting beats from the appropriate states and moves, the model is trained.</p><p><strong>Human: <br></strong>Human can play optimally or randomly.<br>As per the algorithm, If the move is chosen randomly, human randomly selects the empty spot.<br>Or, if chosen optimally, it follows the sequence of following steps:<br>a. Play for win<br>b. Block opponent win<br>c. Fork<br>d. Block Fork<br>e. Play center, if empty<br>f. Play opposite corner<br>g. Play corners, if empty<br>h. Play sides, if empty</p><p><strong>Algorithm</strong>:<br>Creating states by using three integers {0, 1, 2} to generate a nine-digit number. The empty state is “0”, the MENACE move is “1”, and the human move is “2”.We also store a nine-digit number in a HashMap once it is generated.<br>The structure of HashMap is as follows:<br>{<br> “100000002”: [0,9,9,9,9,9,9,9,9,0]<br>}</p><p>The key in the HashMap is the serialized state of the tic-tac-toe game and the value is the empty spots/locations holding respective no. of beats(alpha) in them.<br>The states are being validated before storing in the HashMap based on the following conditions:</p><p>a. As MENACE plays first, therefore there should be the same no. of moves (total no. of 1s and 2s in the state)<br>b. We consider the total moves less than 8 as those are the only crucial ones. After 7 the chances of winning are very less whereas, the chances of drawing are more.<br>c. That state should not be in a “win-win” state.<br>d. Checking if the mirror image is already present in the HashMap</p><p>By following all the validations/filtering conditions, the total no. of states obtained is 304(considering MENACE plays first).<br>Later, when the game begins, We check the state (serialized version) of the game in the HashMap, if it is not present, we check for the mirror images of that particular state in the HashMap.<br>Once the mirror image is found in the HashMap, we replace/rotate or tic-tac-toe board in such a way that the serialized version of the state is equal to the one found in the HashMap.<br>To pick a position/spot to play, we again check the state (serialized version) of the game in the HashMap, if it is not present, we check for the mirror images of that particular state in the HashMap. If the game turn is less than 8 then the state is for the sure present in the HashMap and for later chance, a random no. is given the priority.<br>Once, the state is found in the HashMap we look for its value of it and pick a random index based on the no. of beats(weights). Therefore, a weighted random index algorithm has been used here to pick a random index based on the weights. If the state is not found in the HashMap (for chance more than 7), we pick a random index and play the respective position on the board and move forward.<br>In the human turn, the algorithm has 2 options to play from. Humans can play in a defined optimal step, or it can play randomly. When it’s human’s turn, we first select which method to play with. The selection is done based on a weighted random algorithm, where the weights are assigned according to the probability. For example, if the probability of human playing optimally is 0.9 the weight associated with it will be 9 and the weight to play randomly will be 1. So, the total weight is 10 and it is adjusted accordingly.</p><p>If optimal algorithm is selected, human will follow defined steps which are,<br>1. Check if human can win after this move. If yes, play that move.<br>2. Check if menace is going to win in the next set. If yes, block that move<br>3. Check if human can play fork against menace. If yes, play the fork move<br>4. Check if menace is playing fork. If yes, block the fork<br>5. Check if the center of the board is empty. If yes, play center move.<br>6. Check if a corner opposite to the menace is empty. If yes, play that opposite corner.<br>7. Check if any other corner is empty. If yes, play corners.<br>8. Check if any side is empty. If yes, play that side.</p><p>If the random algorithm is selected, find all the empty positions on the board. Select one position out of these randomly and play that move.</p><p><strong>Invariants</strong>:<br>The following are the invariants in the tic-tac-toe game:<br>1. It follows a class variant, as there are two players in the game, and the no. Xs or Os in each turn is relatable.<br>E.g., No. of O’s are less than X’s, considering X plays first.</p><p>2. To win the game, there are exactly 8 conditions.<br>a. Combination of 3 in a row — count 3<br>b. Combination of 3 in a column — count 3<br>c. Combination of diagonals — count 2</p><p>3. As there are two different players in the game, they play alternatively.</p><p>4. Maximum no. of moves possible is 9. (Menace play max 4 moves)</p><p>5. In case of mirror images and rotation of the board,</p><p>The central positions are never affected while check mirror images, as it’s going to be the same on rotation and mirror of the board.<br>a. Middle row spots can never be at the corner.<br>b. The corner spots are more affected by rotation.</p><p>6. Menace always plays first move.</p><p>7. Menace states are modified as per the chosen path.</p><p><strong>Conclusions</strong>:<br>Based on the graphs, when the Menace plays with the flawlessly playing human, the menace loses in the beginning, but later after around 100 games, Menace learns to block a move to make the game “draw” or “win”.<br>Based on the Human’s random strategy, Menace produces a positive trend after specific no. of games. The positive trend is, it learns to block a move or tries to win by opting a win-win spot. Whereas, based on the Human’s optimal strategy, the response or chances of wins reduces but eventually (after ~95 games) it learns to block a win-win state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*kFVmuF8fSzFAxibeMRgjDg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f37750f8233b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making connections right from your VSCode!]]></title>
            <link>https://prathameshnemade.medium.com/making-connections-right-from-your-vscode-4056035a1356?source=rss-928b2b53ae84------2</link>
            <guid isPermaLink="false">https://medium.com/p/4056035a1356</guid>
            <category><![CDATA[extension]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[svelte]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Prathamesh Nemade]]></dc:creator>
            <pubDate>Mon, 25 Oct 2021 19:21:19 GMT</pubDate>
            <atom:updated>2021-10-25T19:21:19.454Z</atom:updated>
            <content:encoded><![CDATA[<p>Talking to people all over the globe or making connections <strong>right from your IDE</strong>, damn!! What an idea!</p><p>Going through random videos on Youtube, found one of the videos by Ben Awad, which helped me to learn the development of extensions. And guess what, I created one!!</p><p><strong>VSBook</strong> is an extension developed for your VSCode IDE. This extension helps you to make connections and even chat with like-minded peeps around you.</p><p>You can download this extension from the VSCode marketplace. Oh wait, I’ll make this easy. <a href="https://marketplace.visualstudio.com/items?itemName=prathameshnemade.vsbook"><strong><em>Click here</em></strong></a>, to download the extension.</p><p>Trust me, I won&#39;t disappoint you or make you look bored; I’ll try to keep it brief. With the help of VSBook, you can post your code snippet, share your ideas/activities, see activities of other peers around you, and whatnot.</p><p>This is the login page for the VSBook. Once logged in, you can make a post with a single click on the bottom status bar of your VSCode. Also, by selecting the code snippet on your IDE, you can make a post by clicking on the Code Post at the bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UPgecIaclO3k6NPiMce2kw.png" /></figure><p>Once you are logged in, you land on a user’s dashboard page. This gives you a brief idea about your Chat history, all of the posts and also, you can edit your profile too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IcC78b2rInUIo5Cs5EtO1g.png" /></figure><p>Morover, on clicking the profile icon below the name of the person, you get to see the profile of the respective developer. You can go through all the posts, posted by the user also can initiate a chat too. Ain’t this a <strong>Facebook</strong> of VSCode?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZM83WbYzIF5g8VerR2RljQ.png" /></figure><p>According to be, connections are very important when it comes to the Information Technology sector. The major intention of creating/developing this extension is, making connections with the similar-minded people.</p><p>And, <strong>VSBook</strong> does it!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*I4oqWh-R0BrXM5gEBRvqOQ.gif" /></figure><p>Thank you for reading!</p><p>If you found this article helpful, 👏👏👏.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4056035a1356" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“expo-notifications” does not work on the standalone android app!?]]></title>
            <link>https://prathameshnemade.medium.com/expo-notifications-does-not-work-on-the-standalone-android-app-6af9fb9761f7?source=rss-928b2b53ae84------2</link>
            <guid isPermaLink="false">https://medium.com/p/6af9fb9761f7</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[expo-notifications]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Prathamesh Nemade]]></dc:creator>
            <pubDate>Fri, 19 Feb 2021 05:03:59 GMT</pubDate>
            <atom:updated>2021-02-19T05:06:37.537Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>“expo-notifications” does not work on the standalone android app !?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Kpobsz9awRZQ7Iac" /><figcaption>Photo by <a href="https://unsplash.com/@healing_photographer?utm_source=medium&amp;utm_medium=referral">Aarón Blanco Tejedor</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The weirdest thing and the lack of precise documentation, using “<strong>expo-notifications</strong>” on SDK 38 and SDK 40 is a pain.</p><p>The weird piece is, the<strong> getexpoPushTokenAsync()</strong> method works on the Expo Go app but does not return anything in the standalone android app. Well, in case if you are using <strong>async await</strong> and waiting for the token to be returned, the app gets stuck due to this method and worsens the situation. Also it&#39;s hard as well to debug the exact reason for the failure.</p><p>Going through multiple threads, I have managed to find the solution for this.</p><p>Following are the steps to make it work:<br>1) Sign In to your firebase account <a href="https://console.firebase.google.com/"><strong>https://console.firebase.google.com/</strong></a></p><p>2) Create a project.</p><p>3) Once you land on your dashboard, click on <strong>Add app </strong>button and create a <strong>android</strong> app.</p><p>4) Be careful while creating the app, make sure you use the <strong>same app name</strong> and the <strong>exact same bundle identifier </strong>that you have used in your app.json file.</p><p>5) While creating the app, download the <strong>google-services.json </strong>returned by the firebase console.</p><p>6) Add this downloaded google-services.json file to your topmost hierarchy of the workspace and also, register it in your app.json file.</p><p><strong>Note</strong>: Please refer to the below screenshot to get a clean view of this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*ir80_Pamgkk9T5YyktBoaA.png" /></figure><p>7) Moreover, refer to the “<strong>apiKey</strong>” from your <strong>google-services.json</strong> file and register the same in your <strong>app.json</strong> file(refer to above screenshot).</p><p>8) Push the secret key to the expo server by executing the following command:</p><p><strong>expo push:android:upload — api-key &lt;SECRET-KEY&gt;</strong></p><p><strong>Note: </strong>Get the server key from the firebase console. <strong>Project Settings &gt;&gt; Cloud Messaging &gt;&gt; Token is your secret key.</strong></p><p>.…and you are done.</p><p>Build the app, and you can see the <strong>getexpoPushTokenAsync() </strong>method returns you a token.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6af9fb9761f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>