Jewels and stones

From Rosetta Code
Revision as of 08:03, 25 April 2018 by CalmoSoft (talk | contribs) (Created page with "{{Jewels and Stones}} See details: [https://leetcode.com/problems/jewels-and-stones/description/ Jewels and Stones] =={{header|Ring}}== <lang ring> # Project Jewels and Sto...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:Jewels and Stones

See details: Jewels and Stones

Ring

<lang ring>

  1. Project Jewels and Stones
  2. Date 2018/04/25
  3. Author Gal Zsolt (~ CalmoSoft ~)
  4. Email <calmosoft@gmail.com>

jewels = "aA" stones = "aAAbbbb" see jewelsandstones(jewels,stones) + nl jewels = "z" stones = "ZZ" see jewelsandstones(jewels,stones) + nl

func jewelsandstones(jewels,stones)

       num = 0
       for n = 1 to len(stones)
            pos = substr(jewels,stones[n])
            if pos > 0
               num = num + 1
            ok
       next
       return num

</lang> Output:

3
0