{"id":359,"date":"2020-01-30T15:59:51","date_gmt":"2020-01-30T15:59:51","guid":{"rendered":"https:\/\/www.samarthya.me\/wps\/?p=359"},"modified":"2020-01-30T15:59:51","modified_gmt":"2020-01-30T15:59:51","slug":"pangram","status":"publish","type":"post","link":"https:\/\/blog.samarthya.me\/wps\/2020\/01\/30\/pangram\/","title":{"rendered":"Pangram"},"content":{"rendered":"<p>I wrote my first program for Pangram in JS <a href=\"https:\/\/www.samarthya.me\/wps\/2019\/12\/13\/optimizing-in-js\/\">here<\/a> and attempted few variations to optimize the readability and execution time. This time the code challenge was in Golang and it was satisfying attempt to do in first try.<\/p>\n<blockquote>\n<p>Determine if a sentence is a pangram. A pangram (Greek: \u03c0\u03b1\u03bd \u03b3\u03c1\u03ac\u03bc\u03bc\u03b1, pan gramma, &#8220;every letter&#8221;) is a sentence using every letter of the alphabet at least once. The best known English pangram is:<\/p>\n<p style=\"text-align: center;\">The quick brown fox jumps over the lazy dog.<\/p>\n<\/blockquote>\n<p style=\"text-align: left;\">\u00a0<\/p>\n\n\n<pre class=\"wp-block-preformatted\">package pangram\n\nimport \"strings\"\n\n\/\/ Alphabets all the characters.\nconst Alphabets string = \"abcdefghijklmnopqrstuvqxyz\"\n\n\/\/ IsPangram checks for pangram in the inputs string.\nfunc IsPangram(in string) bool {\n    in = strings.ToLower(strings.TrimSpace(in))\n    if in == \"\" {\n        return false\n    }\n\n    for _, v := range Alphabets {\n        if strings.IndexRune(in, v) &lt; 0 {\n            return false\n        }\n    }\n    return true\n}\n<\/pre>\n\n\n\n<p>I could have simplified it further by instead of having the <code>const Alphabets<\/code> just loop through rune <code>'a'<\/code> to <code>'z'<\/code>.<\/p>\n\n\n\n<p class=\"has-text-align-left\">The code is simple enough to go through, where I check in for the index of all the runes in the string <code>Alphabets<\/code> and if any one is not found, it is not a <code>PANGRAM<\/code>.<\/p>\n\n\n\n<p class=\"has-text-align-center\">&#8212; THE &#8211; END &#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A pangram (Greek: \u03c0\u03b1\u03bd \u03b3\u03c1\u03ac\u03bc\u03bc\u03b1, pan gramma, &#8220;every letter&#8221;) is a sentence using every letter of the alphabet at least once. The best known English pangram is:<br \/>\nThe quick brown fox jumps over the lazy dog.<\/p>\n","protected":false},"author":2,"featured_media":361,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[1,34],"tags":[23,20],"class_list":["post-359","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-others","category-technical","tag-golang","tag-pangram"],"_links":{"self":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/comments?post=359"}],"version-history":[{"count":0,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/359\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media\/361"}],"wp:attachment":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media?parent=359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/categories?post=359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/tags?post=359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}