diff --git a/_config.yml b/_config.yml index c6207df..ba9ecd0 100644 --- a/_config.yml +++ b/_config.yml @@ -42,8 +42,8 @@ urls: url: "https://agusmakmun.github.io" baseurl: "" -paginate: 15 -per_page: 15 +paginate: 20 +per_page: 20 paginate_path: "/page:num/" markdown: kramdown gems: diff --git a/_posts/2016-06-11-mdam.md b/_posts/2016-06-11-find-substrings-for-line-encoding-cf.md similarity index 87% rename from _posts/2016-06-11-mdam.md rename to _posts/2016-06-11-find-substrings-for-line-encoding-cf.md index b8cecb6..33e359f 100644 --- a/_posts/2016-06-11-mdam.md +++ b/_posts/2016-06-11-find-substrings-for-line-encoding-cf.md @@ -13,7 +13,7 @@ Next, each substring with length greater than one is replaced with a concatenati for example, substring `"bbb"` is replaced by `"3b"` Finally, all the new strings are concatenated together in the same order and a new string is returned. -####SUBSTRING +#### SUBSTRING A **substring** of a string `S` is another string `S'` that occurs in `S`. For example, `"Fights"` is a substring of `"CodeFights"`, but `"CoFi"` isn't. @@ -23,14 +23,12 @@ For `s = "aabbbc"`, the output should be `lineEncoding(s) = "2a3bc"`. **Input/Output** - * [time limit] 4000ms (py) - * [input] string s (String consisting of lowercase English letters.) +* [time limit] 4000ms (py) +* [input] string s (String consisting of lowercase English letters.) - _Constraints:_ `4 ≤ s.length ≤ 15.` +_Constraints:_ `4 ≤ s.length ≤ 15.` - * [output] string - - Encoded version of s. +* [output] string (Encoded version of s.) **Solution:** diff --git a/_posts/2016-06-11-find-the-number-of-even-digits-in-the-given-integer-cf.md b/_posts/2016-06-11-find-the-number-of-even-digits-in-the-given-integer-cf.md new file mode 100644 index 0000000..4785546 --- /dev/null +++ b/_posts/2016-06-11-find-the-number-of-even-digits-in-the-given-integer-cf.md @@ -0,0 +1,44 @@ +--- +layout: post +title: "Find the number of even digits in the given integer [CF]" +date: 2016-06-11 03:39:03 +0700 +categories: [python, codefights] +--- + +Find the number of even digits in the given integer. + +**Example** + +* For `n = 1010`, the output should be `numberOfEvenDigits(n) = 2`. +* For `n = 123`, the output should be `numberOfEvenDigits(n) = 1`. + +**Input/Output** + +* [time limit] 4000ms (py) +* [input] integer n (A positive integer). + +**_Constraints:_** + +* 1 ≤ n ≤ 106. + +* **[output] integer** + +**My Solution:** + +```python +def numberOfEvenDigits(n): + return len(filter(lambda m: m.isdigit() and int(m) % 2 == 0, str(n))) +``` + +**Rests Tests:** + +``` +n: 1010 +Output: 2 + +n: 123 +Output: 1 + +n: 135 +Output: 0 +``` diff --git a/_posts/2016-06-11-get-month-name-cf.md b/_posts/2016-06-11-get-month-name-cf.md new file mode 100644 index 0000000..63db812 --- /dev/null +++ b/_posts/2016-06-11-get-month-name-cf.md @@ -0,0 +1,48 @@ +--- +layout: post +title: "get Month Name [CF]" +date: 2016-06-11 03:43:45 +0700 +categories: [python, codefights] +--- + +Map the given integer to a month. + +**Example:** + +* For `mo = 1`, the output should be `getMonthName(mo) = "Jan"`, +* For `mo = 0`, the output should be `getMonthName(mo) = "invalid month"`. + +**Input/Output** + +* [time limit] 4000ms (py) +* [input] integer mo (A non-negative integer). +* **Constraints:** `0 ≤ mo ≤ 15`. +* **[output] string** + +A `3`-letter abbreviation of month number `mo` or `"invalid month"` if the month doesn't exist. + +Here are abbreviations of all months: + +**My Solution:** + +```python +def getMonthName(mo): + months = { + 1: "Jan", 2: "Feb", 3: "Mar", 4:"Apr", + 5: "May", 6: "Jun", 7: "Jul", 8:"Aug", + 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec" + } + if mo in months.keys(): + return months.get(mo) + return "invalid month" +``` + +**Result Tests**: + +```python +>>> getMonthName(1) +"Jan" +>>> getMonthName(0) +"invalid month" +>>> +``` \ No newline at end of file diff --git a/static/img/screenshot-post-page.png b/static/img/screenshot-post-page.png index 089e17e..e609ecf 100644 Binary files a/static/img/screenshot-post-page.png and b/static/img/screenshot-post-page.png differ