diff --git a/_config.yml b/_config.yml index c6207dfff77488196a9e7fa9dc17b73b4f5c93ad..ba9ecd03104ba522f21ca72685053f29d89d6a92 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 b8cecb639e41925ef17b6ded1b836e4bae66122a..33e359f86bfa742adc616575a9137b4449102f4a 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 0000000000000000000000000000000000000000..4785546b1c38d8614b2f6821dc7048adab573324 --- /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 0000000000000000000000000000000000000000..63db812edce6a2a800b46e04cf6ca2b84f66aa05 --- /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 089e17ef4794b2b7e5bf8e472cf338d935080cce..e609ecfdf006f9908df214ff9ccf92164b954072 100644 Binary files a/static/img/screenshot-post-page.png and b/static/img/screenshot-post-page.png differ