python |
Pythonタグが付けられた新着投稿 - Qiita |
1/fゆらぎで癒されたい |
https://qiita.com/reika727/items/ecdecba39739ee0ea2d1
|
現代社会 |
2022-07-19 05:20:11 |
海外TECH |
DEV Community |
How to build your own google search |
https://dev.to/samyc2002/how-to-build-your-own-google-search-4i85
|
How to build your own google searchGot interested Yeah we will build an algorithm to make our own search engine There are a couple of steps in doing so First we do some web scraping and index the data we obtain to store it in the database in a meaningful format We won t be doing these here though What we will do is to search what you want from these indexed data So let s get started Problem at handYou suddenly get an urge to build your own google search Your friend is helping you out in the initial stuff but he is really dumb when it comes to algorithms So you need to build an algorithm that can search for a word efficiently from a given list of strings We shall make some assumptions here Firstly we will assume that the strings will be unique and will be comprising of single word each Also the characters of the strings will be from a z NOTE These assumptions are just to deduce the algorithm The algorithm that will be building can handle all characters and also multi word strings These assumptions will just let us deduce the algorithm easily and then we can generalise our algorithm by some minute modifications IntuitionLet s first try to think what we can do in this case One simple option is to hash each string to a value and use the string as and when it is called However there are two problems in this method We need to store the same part of the string twice For example consider these two cases app apple Here it is evident that storing app and apple separately will cause us to use more memory as compared to storing one of them So the question is can we do better Well the answer is yes we can however there are some trade offs for this method We can use something called a trie Tries are efficient information retrieval data structures We can use these to retrieve data more efficiently than arrays they don t have that O time complexity though And guess what Tries take lesser memory than hashmaps SolutionNow let s implement our trie Before we start though I d like to give you a basic structure of a TrieNode basically a node or vertex in the trie struct Node char val Node next class TrieNode unordered map lt char Node gt children bool endOfWord public TrieNode for char c a c lt z c children c NULL endOfWord false This is what a basic trie node looks like Here I took the information in each node as a character It can be anything ranging from a character to complex objects The children map will have all the characters in range here a z as keys and the node for that character s data as the value So once we have that in place now is the time we construct our trie First step is to understand how it will work Basically we will have a starting node let s call this a wildcard character This node will be an empty TrieNode with null pointers as all it s children and endOfWord as false Now we keep on adding the strings in our trie For each string we add one character to the trie s children with the corresponding node s value We repeat unless the string has ended Once it has we mark the endOfWord of that TrieNode as true void insert string word Node curr root for char c word if curr gt children find c curr gt children end curr gt children c new Node curr curr gt children c curr gt endOfWord true We do this for each string we get and at the end we will have our trie completed Good now we have our data in place But how do we query it If you understood it till now you should ve already guessed it However if you are dumb like me then hang on Let s discuss this through So querying it is quite simple For the query word we perform a similar logic and search character by character If at any moment we see that a character that you need to complete the current word is not present we can conclude that the word is not present in the trie and need to go further Case I In case you find the whole word however the last character you visited to doesn t have endOfWord as true then again the word you are searching for doesn t exist In all other cases you can find the word you are searching for Case II Consider the following example for case I a b p e p a l r eSo we have “apple and “bear in our trie Now say you search for “boat You see we have a b but hold on we do not have an o after b Hence “boat doesn t exist in our trie Now say you add “boat to it It d look something like this a b p o e p a a l t r eNow if you search for “boat you can see you will get all the characters and t will also have endOfWord as true Consider the following example for case I a b p o e p a a l t r eNow say you search for “app You notice a is present then p is also present and the next p is also present However this p doesn t have endOfWord set to true Hence “app isn t present in our trie Now if you add “app to our trie it d look something like this a b p o e p a a l t r eAs you can see we marked p with endOfWord true as well in the above case Here is how you implement this in code bool search string word Node curr root for char c word if curr gt children find c curr gt children end return false curr curr gt children c return curr gt endOfWord Also let s discuss a bonus thing you can do with tries You can even predict the words or characters in this case that the user is going to type next It works on the same logic as above with a slight modification Here we just say if the word starts with the prefix string All you need to do to make this into an autosuggestion feature is to put the words into an array and returning it in place of true also change the function return type lol bool startsWith string prefix Node curr root for char c prefix if curr gt children find c curr gt children end return false curr curr gt children c return true With that my lecture is over But you d ask now “Wait You mentioned this is better than hashmaps and started giving a lecture without even asking if I was interested So is it really more efficient than a hasmap So let s try to answer that Here we are traversing through the entire trie and we visit each node in a branch exactly once So the time complexity will be O h in the worst case where h is the height of the trie If you know that the trie has N nodes then you can even say it takes O logN time Yay less than linear The space needed is almost constant as each node has a fixed number in this case of children If the height of tree is h then space taken is O h O h which can also be interpreted as O logN if the number of nodes are N As you can imagine it s pretty efficient as compared the the naive way of using a hashmap to store stuff Sure we d get O search time but we d have taken a lot of memory and we also would ve to give up on the autosuggest featue xP Well with that you ve successfully planned the algorithm to build the next google search What are you waiting for Go and build it Don t keep your friend waiting after he did all that hardwork of doing the initial indexing for you Thanks for reading it till the end and stay tuned for more amazing content like this one |
2022-07-18 20:22:34 |
海外TECH |
DEV Community |
😲 My Top 5 List of Resources that I Wish I Knew When I Started Programming |
https://dev.to/eludadev/my-top-5-list-of-resources-that-i-wish-i-knew-when-i-started-programming-j04
|
My Top List of Resources that I Wish I Knew When I Started ProgrammingFrom courses to tutorials and blogs we all know that the Internet can be an endless trove of information It s the perfect place to learn new things on our own especially when it concerns the skill of programming But with too much greatness comes a serious disadvantage where can we find the best resources I have been in this industry for a very long time so here s my golden list of commodities that I couldn t survive even a day without Connecting with a community of developersLearning web development without classmates makes us prone to loneliness And this goes without emphasizing the importance of team work to share knowledge and to help each other in these hard times When we re around people we gain the privilege of bouncing ideas off each other Anybody who went to bootcamp or college can back me up on this one But for those of us who study exclusively on the net the best alternative is joining online communities to learn from and inform other people The truth about large online communitiesIt s no surprise that joining large groups can be a hassle it s not easy to find your place and it might not even be worth your time My personal recommendation for you is to find a small organization of people and Introduce yourselfHelp existing membersRegularly check in to see what s newBut I know that it s not trivial to discover small communities that s why I want to give you the opportunity to join a small and growing organization called the Open Source Hub Following a professional roadmapThe world of development is confusing it seems like everyday there s a new framework or library being added to your job description Roadmaps were invented to solve this issue with a clear roadmap the student can develop an optimal skill set that your boss can t turn their head away from Every aspect is carefully taken into account Is it future proof Is it demanded in today s job market Can I learn it in a realistic time span When I just started programming there wasn t a good roadmap for me to follow I d probably have finished my studies much faster if I had this great treasure Keeping up with Tech TwitterYou probably didn t expect this one But contrary to popular belief Twitter is a great place to learn new information and to connect with other junior programmers just like you After you create a new account the next step is telling Twitter that your interests lie in programming Follow like minded usersEngage with interesting tweetsAsk questions of your ownI also suggest timing your Twitter feed to show the latest tweets instead For those of you interested in web development I suggest following this list of accounts steveschoger jamesm ChallengesCssThis will keep your Twitter timeline always fresh and full of new and exciting content Printing the most important cheat sheetsThere s a gigantic amount of information that every student needs to learn by heart But sometimes it s just more effective to condense all of that data into a small sheet of paper I just described to you what s known as a “cheat sheet and while those were typically used for cheating on exams as their name suggests they re also important candidates for storing and retrieving repeatable topics Generous developers have compiled an invaluable list of technical cheat sheets for topics ranging from CSS to PHP and SQL Reading one article a day to stay informedThere s no better way to start your day than with an interesting article Do this every day for months and you ll be much more informed than your peers There s an endless trove of websites that offer daily articles related to programming so much that it has become extremely confusing to decide on only one platform I personally solved this issue when I started using daily dev a hub for the best development articles collected from the best networks ConclusionI start my day off by picking an article to read from daily dev scrolling through my Tech Twitter feed just to finally become productive again and begin programming while referring to my roadmap and my cheat sheets When I get stuck I simply refer to my community and connect with other developers to resolve any issue I have EludaFollow follow me for a free cookie ️ More free resourcesI built a collection of button designs right in CSS and HTML It s every design that you could imagine and it s totally free You can get the CSS buttons collection here You cannot miss this I m doing a launch on Product Hunt Product Hunt was the birthplace for Robinhood Gimlet and Houseparty And today my new project will take a stand on it too I can t ask you for upvotes but I would really love your feedback and support Just click the image below and you ll discover what I ve been working on for over months |
2022-07-18 20:10:08 |
Apple |
AppleInsider - Frontpage News |
Apple adds new 'Leaving Soon' section to Apple Arcade, starting with 15 titles |
https://appleinsider.com/articles/22/07/18/apple-adds-new-leaving-soon-section-to-apple-arcade-starting-with-15-titles?utm_medium=rss
|
Apple adds new x Leaving Soon x section to Apple Arcade starting with titlesApple Arcade now has a new Leaving Arcade Soon tab listing titles that will be removed from the service ーstarting with games Apple ArcadeThe tab which was first spotted by TouchArcade is located at the bottom of the Arcade tab in the App Store Read more |
2022-07-18 20:49:21 |
海外TECH |
Engadget |
Amazon makes Prime Video look more like Netflix (and every other streaming app) |
https://www.engadget.com/amazon-prime-video-redesign-announced-204019411.html?src=rss
|
Amazon makes Prime Video look more like Netflix and every other streaming app Amazon is introducing a new Prime Video interface that will be familiar to anyone who has used Netflix or for that matter any other modern streaming service To make the Prime Video experience “less busy and overwhelming the company has relocated the platform s main navigation bar to the left side of the screen and arranged the icons into a vertical column From top to bottom the six menus are Search Home Store Live TV Free and My Stuff Most of the menus include subcategories to simplify navigation further For instance the Home section has subcategories for movies TV shows and sports Other Netflix inspired features include a top list of popular content and poster style thumbnails that expand to play a preview when you navigate over them AmazonHowever the most helpful change Amazon has introduced is a new set of icons that make it easier to know if something is part of Prime Video A blue checkmark means the TV show or movie you want to watch is included with your subscription By contrast a gold shopping bag means you need to either buy or rent the content to view it nbsp According to The Verge Amazon spent months working on the redesign Ben Smith vice president of product for Prime Video and Prime studios led the project Notably he previously worked on Hulu s redesign That effort saw the service try something radically different only for it to return to a more familiar design a few years later AmazonAmazon will begin rolling out the new Prime Video experience starting this week The redesign will first arrive on Android and compatible streaming devices ーincluding Roku Fire TV and Apple TV ーbefore landing on iOS and the web later this year nbsp The new experience won t roll out to every device where Prime Video is available and among the more notable omissions are the third generation Apple TV and Sony s PlayStation If either of those are how you watch Prime Video you won t lose access to the service as a result ーyou ll just have to get by without the redesigned interface for the time being |
2022-07-18 20:40:19 |
海外TECH |
Engadget |
Bungie sues 'Destiny 2' player over alleged threats and cheating |
https://www.engadget.com/bungie-destiny-2-player-lawsuit-cheating-harassment-200942428.html?src=rss
|
Bungie sues x Destiny x player over alleged threats and cheatingOn the same day it officially became a PlayStation studio Bungie filed a lawsuit against a Destiny player it accused of persistent cheating and making threats against its employees The developer claimed Luca Leone violated the game s Limited Software License Agreement LSLA on multiple occasions It s seeking in damages and an injunction preventing Leone from “harassing stalking or otherwise engaging in unwanted or unsolicited contact with Bungie its employees or Destiny players as Kotaku nbsp reports Bungie said it banned Leone multiple times for using Destiny cheat software while streaming on Twitch In an attempt to evade the ban Leone created accounts each of which constituted a fresh breach of the LSLA according to the filing The studio claimed Leone violated the LSLA on other fronts including by selling Destiny accounts that contain emblems or non transferable badges that players can earn Bungie says these quot are prized by many players especially collectors quot In addition Bungie claims that Leone has made threats regarding the studio and its employees According to the suit Leone tweeted quot about his desire to burn down Bungie s office building and wrote that specific Bungie employees were not safe given Leone s intent to move into their neighborhood quot In May an image of Destiny community manager Dylan Gafner s employee badge appeared on a Twitter account that s said to belong to Leone quot I just realized I ll be moving to a place that s minutes away from dmg Leone allegedly wrote followed by “he is not safe quot Bungie notes that quot dmg quot likely refers to Gafner who uses the Twitter handle dmg Leone s purported Twitter account has since been locked His reported Twitch channel features no content other than a bio reading quot year old Bungie playtester from Los Angeles quot Engadget has contacted Leone for comment The filing follows a number of instances of harassment against game developers Forbes Paul Tassi wrote that Destiny sandbox design lead Kevin Yanes has all but left Twitter Players reportedly reacted with fury to Yanes saying an item from the original Destiny will not return quot I dream of a day where videogame developers from any studio can openly discuss their work without being harassed quot Gafner wrote on Twitter on Saturday Cases of harassment against our developers have actively made it harder for us to communicate with the broader community It has impacted more studios than just ours I hope that more folks can stand against this behavior in any community whether it be gaming related or other ーdmg A dmg July A few weeks ago Sony Santa Monica developers received threats and unsolicited photos of genitalia for not revealing the God of War Ragnarök release date when the studio was reportedly planning to Sony Santa Monica announced the release timing just a few days later This isn t the first time Bungie has targeted players with legal action Just last month it sued someone who allegedly uploaded music from the Destiny soundtrack for filing fake DMCA notices against content creators |
2022-07-18 20:09:42 |
海外科学 |
NYT > Science |
Covid Rises Across U.S. Amid Muted Warnings and Murky Data |
https://www.nytimes.com/2022/07/18/us/covid-us-outlook.html
|
Covid Rises Across U S Amid Muted Warnings and Murky DataBA a highly transmissible variant is dominating a surge of new infections Many health officials say the wave is cause for caution not alarm |
2022-07-18 20:31:47 |
ニュース |
@日本経済新聞 電子版 |
IEA、欧州に「ガス消費抑制」警告 ロシア産調達不安で
https://t.co/GpXka8uzxg |
https://twitter.com/nikkei/statuses/1549127545261817857
|
警告 |
2022-07-18 20:22:42 |
ニュース |
@日本経済新聞 電子版 |
選手村マンションの「晴海フラッグ」、応募倍率111倍も
https://t.co/s2jXIWEmEH |
https://twitter.com/nikkei/statuses/1549127544233857024
|
選手村 |
2022-07-18 20:22:42 |
ニュース |
@日本経済新聞 電子版 |
NYダウ反落、215ドル安 業績懸念の高まりで
https://t.co/h5YnVpm5Km |
https://twitter.com/nikkei/statuses/1549127541926965248
|
業績 |
2022-07-18 20:22:42 |
ニュース |
@日本経済新聞 電子版 |
ウクライナ、ロシア軍の弾薬庫集中攻撃か 補給乱れ狙う
https://t.co/KOtab3Z6tz |
https://twitter.com/nikkei/statuses/1549125263157383168
|
集中 |
2022-07-18 20:13:38 |
ニュース |
BBC News - Home |
UK heatwave: Temperature tops 38C and likely to rise on Tuesday |
https://www.bbc.co.uk/news/uk-62201793?at_medium=RSS&at_campaign=KARANGA
|
suffolk |
2022-07-18 20:35:35 |
ニュース |
BBC News - Home |
Richmond: Missing teenager presumed drowned in the Thames |
https://www.bbc.co.uk/news/uk-england-london-62213965?at_medium=RSS&at_campaign=KARANGA
|
london |
2022-07-18 20:35:30 |
ニュース |
BBC News - Home |
England women v South Africa women: Brilliant Tammy Beaumont hits flurry of fours to reach ton |
https://www.bbc.co.uk/sport/av/cricket/62211056?at_medium=RSS&at_campaign=KARANGA
|
England women v South Africa women Brilliant Tammy Beaumont hits flurry of fours to reach tonEngland batter Tammy Beaumont puts on a dominant display hitting three fours in an over against South Africa before bringing up her century in the third ODI in Leicester |
2022-07-18 20:34:24 |
ニュース |
BBC News - Home |
England v South Africa: Tammy Beaumont century helps hosts to comfortable win in third ODI |
https://www.bbc.co.uk/sport/cricket/62209625?at_medium=RSS&at_campaign=KARANGA
|
England v South Africa Tammy Beaumont century helps hosts to comfortable win in third ODIA brilliant century from Tammy Beaumont helps England to a dominant run win in the third one day international against South Africa |
2022-07-18 20:53:26 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
W合格時の最新進学率【早慶上理編】過去5年データ比較で「真の人気序列」判明 - 大学2022 劇変の序列・入試・就職 |
https://diamond.jp/articles/-/306454
|
|
2022-07-19 05:25:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
遊園地「無事故」にかかるお金とは?ジェットコースター1両に“1億円超え”も - テーマパークの「知られざるお金」 |
https://diamond.jp/articles/-/306213
|
限り |
2022-07-19 05:20:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
23年大学入試はどうなる?私大入学定員厳格化が緩和へ、共通テストは易化か - 大学2022 劇変の序列・入試・就職 |
https://diamond.jp/articles/-/306453
|
|
2022-07-19 05:15:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
アマゾンが、世界最速「量子コンピューター」を論文掲載翌日にAWSで提供できた理由 - 号砲! 量子レース |
https://diamond.jp/articles/-/306339
|
量子コンピューター |
2022-07-19 05:10:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
日経平均「3万円回復」が22年後半に?日本株の上昇率が米国株を上回る固有の事情 - 政策・マーケットラボ |
https://diamond.jp/articles/-/306392
|
上方修正 |
2022-07-19 05:05:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
インフレ放置か連鎖破綻か、西側が明け暮れたパワーゲーム失敗の代償 - World Voice |
https://diamond.jp/articles/-/305969
|
worldvoice |
2022-07-19 05:02:00 |
北海道 |
北海道新聞 |
女子マラソン、松田瑞生は9位 世界陸上 |
https://www.hokkaido-np.co.jp/article/707236/
|
世界選手権 |
2022-07-19 05:22:11 |
北海道 |
北海道新聞 |
大谷は1番DH、先発登板はせず 大リーグのオールスター戦 |
https://www.hokkaido-np.co.jp/article/707244/
|
大谷翔平 |
2022-07-19 05:12:00 |
北海道 |
北海道新聞 |
<社説>首都圏へ送電線 再エネ拡充する機会に |
https://www.hokkaido-np.co.jp/article/707219/
|
首都圏 |
2022-07-19 05:01:00 |
ビジネス |
東洋経済オンライン |
「82歳の講師」が教壇に立つ深刻すぎる教員不足 教員の自己犠牲で成り立つ公立学校は崩壊寸前 | 最新の週刊東洋経済 | 東洋経済オンライン |
https://toyokeizai.net/articles/-/604150?utm_source=rss&utm_medium=http&utm_campaign=link_back
|
公立学校 |
2022-07-19 05:30:00 |
コメント
コメントを投稿