開源日報 每天推薦一個 GitHub 優質開源項目和一篇精選英文科技或編程文章原文,堅持閱讀《開源日報》,保持每日學習的好習慣。
今日推薦開源項目:《文字識別 tesseract.js》
今日推薦英文原文:《Do You Know How to Solve These Programming Problems?》
開源日報第648期:《文字識別 tesseract.js》
今日推薦開源項目:《文字識別 tesseract.js》傳送門:GitHub鏈接
推薦理由:OCR——Optical Character Recognition,即光學字元識別,簡單地說就是獲取特定圖片上的文字的過程。這個項目是純 JS 實現的各種語言的 OCR,除了常用的中英文以外提供了相當多語言的支持以防患於未然,即使拋開不常用的語言不提,這個項目的功能依然足夠日常使用,通過項目提供的各種示例可以輕鬆上手。
開源日報第648期:《文字識別 tesseract.js》
今日推薦英文原文:《Do You Know How to Solve These Programming Problems?》作者:Daan
原文鏈接:https://medium.com/better-programming/do-you-know-how-to-solve-these-programming-problems-18d04defc05e
推薦理由:一些演算法小題目

Do You Know How to Solve These Programming Problems?

Can you wrap your head around all of them?

Programming is about solving problems. In this piece, I』ve listed six programming problems from several sites that contain programming problems. The problems in this listed are sorted based on how difficult they are to solve — with number one on this list being the easiest, and number six being the most difficult to solve. Can you wrap your head around all of them? I provided the solutions to these programming problems, coded in PHP, at the bottom of this article. You can choose a programming language of your choice to solve these problems. Good luck solving these problems, and happy coding! Challenges

1. Plus Minus

開源日報第648期:《文字識別 tesseract.js》 Let』s start with a relatively easy problem provided by HackerRank. This challenge is categorized as a warmup.

2. Two Sum

開源日報第648期:《文字識別 tesseract.js》 A challenge that』s considered easy, provided by LeetCode.

3. Largest palindrome product

開源日報第648期:《文字識別 tesseract.js》 This problem is provided by Project Euler and is considered one of the more easy problems. It』s currently solved by more than 455,000 people.

4. Distinct powers

開源日報第648期:《文字識別 tesseract.js》 Another challenge from Project Euler. This one is a little bit harder than the previous problem. It』s solved by around 100,000 people.

5. Kaprekars Constant

開源日報第648期:《文字識別 tesseract.js》 If you』ve made it up to this point: Congratulations! It』s time to start the first hard challenge. This challenge is provided by Coderbyte.

6. Swap Nodes in Pairs

開源日報第648期:《文字識別 tesseract.js》 Definitely the toughest challenge so far, this challenge is provided by LeetCode. Although it』s considered to be of medium difficulty, I found this one harder to solve than the Kaprekars Constant. This one requires you to know how linked lists work.

Solutions

1. Plus Minus

A really great problem to get you started with a solution that』s really straightforward.

2. Two Sum

Although this one』s a little bit harder than the first problem, you shouldn』t have too much trouble solving this one. I used a simple brute-force approach.

3. Largest palindrome product

The solution I came up with has the advantage it can be used to find the biggest palindrome that』s the product of any two x-digit numbers. I』ve also added stop conditions to avoid unnecessary extra looping.

4. Distinct powers

I solved the distinct powers problem by going the brute-force route. Add each result to the array, and then remove duplicates from the array. The last step is to sort the array.

5. Kaprekars Constant

The Kaprekars Constant problem is a little bit harder to solve. It』s the first problem in this list that requires recursion to solve the problem. 開源日報第648期:《文字識別 tesseract.js》 A screenshot of passing all test cases

6. Swap Nodes in Pairs

This one took me a while to figure out. The trick in my solution is to pass variables by reference instead of by value. Still, this one might take some time to get your head around. 開源日報第648期:《文字識別 tesseract.js》
下載開源日報APP:https://openingsource.org/2579/
加入我們:https://openingsource.org/about/join/
關注我們:https://openingsource.org/about/love/