Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more simplifications
  • Loading branch information
JohnEarnest committed Jul 31, 2015
1 parent 0920b15 commit c18caa5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/strings.k
Expand Up @@ -8,16 +8,16 @@ r: {y@(#y)!x+!#y}; / rotate list y by x
(

{?x^?x}"applause" / 1. find duplicated characters
{(x@<x)~(y@<y)}["teapot";"toptea"] / 2. are two strings anagrams?
{(x@<x)~y@<y}["teapot";"toptea"] / 2. are two strings anagrams?
{*t^x^t:?x}"oorning" / 3. first unique character
|"backwards" / 4. reverse a string
&/{(x<58)&x>47}`i$"697" / 5. string contains only digits?
&/{(x<58)&x>47}"697" / 5. string contains only digits?
{+(!t;1+#:'. t:=x^?x)}"Programmming" / 6. find duplicates and their count
{+/'(x;~x)}@^"aeiouy"?"verbage" / 7. count vowels and consonants
+/=["skimmed";"m"] / 8. count occurrences of a character
."231" / 9. convert numeric string to int
{(#z)_,/(z,)'y\x}["x y z";" ";"%20"] / 10. replace character with a string
(p:{$[2>#x;x;,/{x,/:p[y]}.'(0 1_)'r[1]\x]})["xyz"] / 11. permutations of a string
(p:{$[2>#x;x;,/x{x,'y}'p'(x^)'x]})["xyz"] / 11. permutations of a string
" "/|:'" "\"a few words"; / 12. reverse words in a sentence
{x~|x}"racecar" / 13. is a string a palindrome?
?"bananas" / 14. unique characters in order
Expand Down

0 comments on commit c18caa5

Please sign in to comment.