{"id":3207,"date":"2018-08-01T00:01:13","date_gmt":"2018-08-01T07:01:13","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=3207"},"modified":"2018-08-09T08:46:39","modified_gmt":"2018-08-09T15:46:39","slug":"duplicated-letters","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=3207","title":{"rendered":"Duplicated Letters"},"content":{"rendered":"<p>I&#8217;ve been working on a program that counts unique words in a text file. It&#8217;s an interesting exercise and explores the larger realm of pattern matching. You can try such scanning on a smaller scale by coding a program that counts the frequency of letters within a string. And that task is presented as this month&#8217;s Exercise.<br \/>\n<!--more--><br \/>\nStart by prompting the user for string input. Have your code scan the string to determine whether any letters &mdash; A to Z, case-insensitive &mdash; appear more than once. If so, the duplicated letters are displayed. When no letters repeat, the string is flagged as having all unique letters.<\/p>\n<p>Here&#8217;s a sample run:<\/p>\n<p><code>Enter text: Unique words<br \/>\nLetter u repeats<\/code><\/p>\n<p>And one to pass the test:<\/p>\n<p><code>Enter text: Ugly Ed is an ox<br \/>\nString is unique: No two letters repeat.<\/code><\/p>\n<p>You need not get fancy with the way the repeated letters are flagged. For example, my solution just coughs up a letter the first time it&#8217;s duplicated:<\/p>\n<p><code>Enter text: My solution is nothing fancy.<br \/>\nLetter o repeats<br \/>\nLetter i repeats<br \/>\nLetter s repeats<br \/>\nLetter n repeats<br \/>\nLetter o repeats<br \/>\nLetter t repeats<br \/>\nLetter i repeats<br \/>\nLetter n repeats<br \/>\nLetter n repeats<br \/>\nLetter y repeats<\/code><\/p>\n<p>If you like, you can write code that counts the duplicated letters and displays a tally, but this solution is optional. Also, it&#8217;s not necessary to distinguish between uppercase and lowercase letters; the code should be case-insensitive.<\/p>\n<p>Please try this Exercise on your own before you check out <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=3218\">my solution<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scan a string to determine how many times a specific letter appears. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=3207\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3207","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3207"}],"version-history":[{"count":5,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3207\/revisions"}],"predecessor-version":[{"id":3243,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3207\/revisions\/3243"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}