-4
\$\begingroup\$

Your code may not contain the letter "e", but must count the number of "e"s in the inputted string and output that as a number. Bonus points if you use a language that is not a codegolf language and a language that actually uses the letter e (unlike brainfuck) --- not a required criteria.

\$\endgroup\$

closed as unclear what you're asking by a spaghetto, NoOneIsHere, Rɪᴋᴇʀ, Sriotchilism O'Zaic, Comrade SparklePony Jun 4 '17 at 23:24

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ Case sensitive, I assume? \$\endgroup\$ – DJMcMayhem Jun 4 '17 at 21:50
  • \$\begingroup\$ Up to your discretion \$\endgroup\$ – vityavv Jun 4 '17 at 22:03
  • \$\begingroup\$ Is it okay if output is in unary? \$\endgroup\$ – Comrade SparklePony Jun 4 '17 at 23:18
  • \$\begingroup\$ yes @ComradeSparklePony \$\endgroup\$ – vityavv Jun 4 '17 at 23:37
  • 5
    \$\begingroup\$ Edit: New challenge! Don't use the characters "101" Please don't arbitrarily change the rules once answers have been posted. For future challenges I advise you to use the sandbox before posting here \$\endgroup\$ – Luis Mendo Jun 4 '17 at 23:56

14 Answers 14

4
\$\begingroup\$

Japt, 7 6 4 bytes

Nope, definitely didn't use e!

è'Ev

Try it online


Explanation

    :Implicit input of string U
è   :Count.
'E  :"E".
v   :Convert to lowercase.
    :Implicit output of result.
\$\endgroup\$
  • 2
    \$\begingroup\$ Nice. I had this, èEsG, èdcÄ, and èfcÉ \$\endgroup\$ – ETHproductions Jun 5 '17 at 1:21
3
\$\begingroup\$

MATL, 5 bytes

101=s

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Mathematica, 42 bytes

#~StringCount~StringDrop[ToString[2<1],4]&

input

["dfhjkeehjke"]

output

3

\$\endgroup\$
  • \$\begingroup\$ You can save a byte by using infix notation: ToString[2<1]~StringDrop~4 as the second argument to StringCount. \$\endgroup\$ – Greg Martin Jun 4 '17 at 22:56
  • \$\begingroup\$ or infix StringCount \$\endgroup\$ – J42161217 Jun 4 '17 at 23:01
1
\$\begingroup\$

CJam, 8 bytes

q'd)f=:+

Case sensitive.

Try it online!

Explanation

q             Read input string
    f=        For each character in that string, see if it equals
 'd           character "d"
   )          increased by 1 (that is, character "e")
      :+      Sum the results. Implicitly display
\$\endgroup\$
1
\$\begingroup\$

brainf***, 215 bytes

case sensitive

+[>>>>+++++[-<++>]<[-<++++++++++>]<[-<<->>]<<-[>-<[-]]>+<,]>[>>+>+<<<-]>>>[<<<+>>>-]<<+>[<->[>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]++++++++[<++++++>-]>[<<+>>-]>[<<+>>-]<<]>]<[->>++++++++[<++++++>-]]<[.[-]<]<

155 of the bytes are from printing the number, from here.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Jelly, 5 bytes

Oċ“d’

A monadic link returning the count.

Try it online!

How?

Oċ“d’ - Link: list of characters
O     - cast to ordinals
  “d’ - base 250 number 101
 ċ    - count occurrences

Alternatives:
O’ċȷ2 - decrement () and count occurrences of 100 (ȷ2);
ƓO’ċ³ - evaluate a line from STDIN (Ɠ), decrement () and count occurrences of 100 (³)

\$\endgroup\$
  • \$\begingroup\$ It's unfortunate that using an argument instead of STDIN overwrites the ³ == 100 mapping. \$\endgroup\$ – DJMcMayhem Jun 4 '17 at 23:35
  • \$\begingroup\$ I really like how you used base 250 number 101 \$\endgroup\$ – vityavv Jun 4 '17 at 23:39
  • \$\begingroup\$ @DJMcMayhem Yes, that and ⁹==256 do bite the count fairly often (pun-intended), and occasionally ⁸==“”. \$\endgroup\$ – Jonathan Allan Jun 4 '17 at 23:41
1
\$\begingroup\$

APL, 9 bytes

2 bytes saved thanks to @Adam

≢⍞∩22⊃⎕AV

How?

    22⊃⎕AV  ⍝ 'e'
 ⍞∩         ⍝ intersect with input
≢            ⍝ count
\$\endgroup\$
  • \$\begingroup\$ Save two bytes: ≢⍞∩22⊃⎕AV \$\endgroup\$ – Adám Jun 4 '17 at 22:41
  • \$\begingroup\$ @Adám thanks! can always be used for single element indexing? \$\endgroup\$ – Uriel Jun 4 '17 at 23:34
  • \$\begingroup\$ For single elements from a vector, yes. However. \$\endgroup\$ – Adám Jun 4 '17 at 23:46
0
\$\begingroup\$

CJam, 10 bytes

It's annoying that the operation to count the number of instances, e=, contains an e.

q"&dd<":)~

This creates a string &dd< , increments every code point to get 'ee=, and then executes it.

\$\endgroup\$
0
\$\begingroup\$

Python 3, 30 26 24 bytes

Extremely basic:

lambda s:s.count('\x65')

4 bytes off thanks to @Challenger's suggestion (adapted to this solution).

51 46 44 bytes, but I like it better:

lambda s:''.join('1'for i in s if i=='\x65')

Output is in unary. I found it first in the hopes that the other way was impossible; for once I'm annoyed that Python lets me do things the easy way.

5 bytes off thanks to @Challenger.

2 bytes off of each thanks to @xnor.

Attribution for the simple method: https://stackoverflow.com/questions/1155617/count-occurrence-of-a-character-in-a-string

Attribution for the unary one: https://stackoverflow.com/questions/1450897/python-removing-characters-except-digits-from-string

\$\endgroup\$
  • \$\begingroup\$ You can golf the second solution: lambda s:''.join('1'for i in s if i==chr(101)) \$\endgroup\$ – Esolanging Fruit Jun 4 '17 at 21:59
  • \$\begingroup\$ @Challenger5 change the input() to s and that'll work \$\endgroup\$ – caird coinheringaahing Jun 4 '17 at 22:00
  • \$\begingroup\$ You can write 'e' as '\x65'. \$\endgroup\$ – xnor Jun 4 '17 at 22:03
  • \$\begingroup\$ if i=='\x65' => if'\x65'==i \$\endgroup\$ – Zacharý Jul 13 '17 at 19:47
0
\$\begingroup\$

Aceto, 21 19 bytes

Ic!_
o=ML
d'I`
,dOp

We read a character and duplicate it, then push a "d" and increment its value to have an e. We then store the equality with M. Now we invert the input to get True when we're done, and conditionally jump to the print command at the end. Otherwise, we load our other truth value (whether it was an e), conditionally increment, and jump back to the Origin.

\$\endgroup\$
0
\$\begingroup\$

PHP, 27 Bytes

<?=count_chars($argn)[101];

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Scala, 20 bytes

_.count(_=='\u0065')

Try it online!

\$\endgroup\$
0
\$\begingroup\$

05AB1E, 4 bytes

Ƶ0ç¢

Try it online!

Ƶ0   # Push 101
  ç  # Convert to a character
   ¢ # Count the occurrences of that character
\$\endgroup\$
0
\$\begingroup\$

Retina, 11 bytes

T`d-f`_f_
f

Try it online! e is indirectly referred to in the translation by creating a range from d to f. The ds and fs are deleted and the es are translated to fs (we can't use d because that would expand to 0-9). It then suffices to count the fs.

\$\endgroup\$
  • \$\begingroup\$ [d-f-[df]] saves one byte. \$\endgroup\$ – Cows quack Jun 5 '17 at 3:42
  • \$\begingroup\$ @KritixiLithos I had no idea you could do that; I think you should go ahead and post that as your own answer. \$\endgroup\$ – Neil Jun 5 '17 at 7:52
  • \$\begingroup\$ Since the challenge is closed, I can't. But I found a large improvement, \x65 for just 4 bytes. \$\endgroup\$ – Cows quack Jun 5 '17 at 7:59
  • \$\begingroup\$ @KritixiLithos Ah of course, use of decimal/hex codes was why the challenge got closed in the first place... \$\endgroup\$ – Neil Jun 5 '17 at 8:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.