From c93580f19290c32b95f55b580b5f553055db0446 Mon Sep 17 00:00:00 2001 From: agusmakmun Date: Sat, 11 Jun 2016 03:16:04 +0700 Subject: [PATCH] added new features --- _config.yml | 12 +++--- _data/projects.json | 21 +++++++--- _includes/analytics.html | 10 ----- _includes/share-page.html | 18 +++++---- _includes/social_links.html | 7 ---- _layouts/default.html | 22 +++++++++-- _layouts/project.html | 6 +-- _posts/2016-06-11-mdam.md | 68 ++++++++++++++++++++++++++++++++ index.html | 2 +- projects.md | 2 +- static/css/main.css | 6 +++ static/css/projects.css | 13 +++--- static/css/thickbox.css | 22 +++++------ static/js/thickbox-compressed.js | 2 +- 14 files changed, 146 insertions(+), 65 deletions(-) delete mode 100644 _includes/analytics.html delete mode 100644 _includes/social_links.html create mode 100644 _posts/2016-06-11-mdam.md diff --git a/_config.yml b/_config.yml index 4a52f44..c6207df 100644 --- a/_config.yml +++ b/_config.yml @@ -3,7 +3,7 @@ description: My Personal Stack Problems author: Agus Makmun github: https://github.com/agusmakmun about: I am freelance developer. Currently doing more in backend, actually in Python and Django. -disqus_shortname: aboutashu +disqus_shortname: stackproblems google_analytics: UA-XXXXXXXX-Y enableTags: true @@ -20,15 +20,15 @@ social: - icon: fa-skype link: "#" - icon: fa-twitter - link: "#" + link: "https://twitter.com/agusmakmun6" - icon: fa-linkedin link: "#" - icon: fa-stack-exchange link: "#" share: - twitter_username: 216ashutosh - fb_appid: 0000000000000 + twitter_username: agusmakmun6 + fb_appid: 1749788565247320 urls: - text: About Me @@ -42,8 +42,8 @@ urls: url: "https://agusmakmun.github.io" baseurl: "" -paginate: 20 -per_page: 20 +paginate: 15 +per_page: 15 paginate_path: "/page:num/" markdown: kramdown gems: diff --git a/_data/projects.json b/_data/projects.json index c52980c..a80e31a 100644 --- a/_data/projects.json +++ b/_data/projects.json @@ -3,7 +3,7 @@ "slug": "cool-project", "name": "Cool project 1", "image": "placeholder.jpg", - "url": "#", + "url": "https://www.google.com", "date": "Jan 2014", "tags": ["Angular JS","API"] }, @@ -12,20 +12,31 @@ "image": "placeholder.jpg", "url": "#", "date": "May 2014", - "tags": ["Android","PHP"] + "tags": ["Python","Django"] }, { "name": "Cool project 3", "image": "placeholder.jpg", "url": "#", "date": "June 2014", - "tags": ["HTML","JQuery","PHP"] + "tags": ["HTML","JQuery","Django"] }, { "name": "Cool project 4", "image": "placeholder.jpg", "date": "Oct 2016", - "tags": ["Android","nodejs"] + "tags": ["Python","nodejs"] + }, + { + "name": "Cool project 5", + "image": "placeholder.jpg", + "date": "Oct 2016", + "tags": ["Python","nodejs"] + }, + { + "name": "Cool project 6", + "image": "placeholder.jpg", + "date": "Oct 2016", + "tags": ["Python","nodejs"] } - ] \ No newline at end of file diff --git a/_includes/analytics.html b/_includes/analytics.html deleted file mode 100644 index bb6b281..0000000 --- a/_includes/analytics.html +++ /dev/null @@ -1,10 +0,0 @@ - \ No newline at end of file diff --git a/_includes/share-page.html b/_includes/share-page.html index 53355c7..9f623a6 100644 --- a/_includes/share-page.html +++ b/_includes/share-page.html @@ -1,14 +1,16 @@
- Share this on → - - + Share this on →   + + + + - -
- + +
+ - -
+ +
@@ -105,7 +113,13 @@ {% endif %} - {% include social_links.html %} +
+ +
diff --git a/_layouts/project.html b/_layouts/project.html index e598f44..9705b43 100644 --- a/_layouts/project.html +++ b/_layouts/project.html @@ -33,14 +33,14 @@ layout: default {% endif %} {% endfor %} {% if p_url == nil %}{% assign p_url = i.url %}{% endif %} - {% if p_url %}{% endif %} + {% if p_url %}{% endif %}

{{ i.name }}

{% if p_url %}
{% endif %}
{% if i.tags %} {% for j in i.tags %} - {{ j }} + {{ j }} {% endfor %} {% endif %}
@@ -48,7 +48,7 @@ layout: default
diff --git a/_posts/2016-06-11-mdam.md b/_posts/2016-06-11-mdam.md new file mode 100644 index 0000000..b8cecb6 --- /dev/null +++ b/_posts/2016-06-11-mdam.md @@ -0,0 +1,68 @@ +--- +layout: post +title: "Find Substrings for line Encoding [CF]" +date: 2016-06-11 03:04:23 +0700 +categories: [python, codefights] +--- + +Given a string, return its encoding defined as follows: + +First, the string is divided into the least possible number of disjoint **substrings** consisting of identical characters +for example, `"aabbbc"` is divided into `["aa", "bbb", "c"]` +Next, each substring with length greater than one is replaced with a concatenation of its length and the repeating character +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 + +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. + +**Example** + +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.) + + _Constraints:_ `4 ≤ s.length ≤ 15.` + + * [output] string + + Encoded version of s. + +**Solution:** + +```python +import re +def lineEncoding(s): + grub = [ m.group(0) for m in re.finditer(r"(\w)\1*", s )] + numb = 0 + out = [] + for i in grub: + numb += 1 + if len(i) > 1: + out.append(grub[numb-1].replace(grub[numb-1], str(len(i))+i[0])) + else: + out.append(i) + return ''.join(out) +``` + +**Result Tests:** + +```python +>>> +s = "aabbbc" +>>> lineEncoding(s) +"2a3bc" +>>> +>>> s = "abbcabb" +>>> lineEncoding(s) +"a2bca2b" +>>> +>>> s = "abcd" +>>> lineEncoding(s) +"abcd" +>>> +``` \ No newline at end of file diff --git a/index.html b/index.html index 8e862b2..78476a6 100644 --- a/index.html +++ b/index.html @@ -13,7 +13,7 @@ layout: default {% if paginator.total_pages > 1 %} -