-2
\$\begingroup\$

This question already has an answer here:

or is a dubious esoteric programming language. The author is unknown but it is known that fungot (a chatbot) is currently learning or but it remains unknown how it does it and where it receives the required material to learn or. Check out this IRC log to see fungot revealing part of the language.

Instruction reference

It is only known that a space followed by an f pushes false to the stack. The false value may by any falsy value of your choosing. (You are allowed to set this falsy value to f prepended with a space, of course.) Since this language does not support output, in order to make verifying answers possible, you should output the resulting stack in the end of the program.

In other words, count the number of appearances of this exact text f prepended with a space in unary.

Test cases

Expects one false to the stack

 f

Expects 2 falses on the stack

m f ma f

Expects 1 false on the stack

 f a lf 

Expects 2 falses on the stack

a f fa

Scoring

This is , so shortest answer in bytes wins.

\$\endgroup\$

marked as duplicate by Luis Mendo, caird coinheringaahing, pppery, Community Oct 21 at 23:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ what does our code even have to do? After reading this question, I have absolutely no idea. Do we have to count "f" characters in the input? \$\endgroup\$ – someone Oct 21 at 14:09
  • \$\begingroup\$ Whoops, the documentation is a bit unclear. You have to count the number of the two characters space and f consecutively. (In other words, count the appearances of the exact text f prepended with a space.) \$\endgroup\$ – A _ Oct 21 at 14:15
  • \$\begingroup\$ Can our falsy value be f prepended by a space? \$\endgroup\$ – someone Oct 21 at 14:35
  • 1
    \$\begingroup\$ So the 'falsy' value may actually be truthy, right? \$\endgroup\$ – Arnauld Oct 21 at 14:54
  • 2
    \$\begingroup\$ I got confused with the backstory. It looks like all that’s needed is Count the number of appearances of this exact text f prepended with a space in unary. Can you confirm? \$\endgroup\$ – Luis Mendo Oct 21 at 15:44
3
\$\begingroup\$

Pyth, 9 8 bytes

*]0/z" f

Try it online!

Alternatively, to print nice falses: *]!1/z" f

-1 byte thanks to @FryAmTheEggman

\$\endgroup\$
  • \$\begingroup\$ @FryAmTheEggman: I forgot about the single-element list constructor, thanks! \$\endgroup\$ – randomdude999 Oct 21 at 14:44
2
\$\begingroup\$

Python 3, 38 26 bytes

lambda s:[0]*s.count(" f")

Thanks to:
- @A_ for saving me 12 bytes

Try it online!

\$\endgroup\$
  • \$\begingroup\$ 26B Try it online! \$\endgroup\$ – A _ Oct 21 at 14:33
  • \$\begingroup\$ @A_ Thanks :), is it possible that you specify the output even more? Do I have to output an array with false values or is an int value with the occurrence of the pattern? \$\endgroup\$ – Delta Oct 21 at 14:36
  • \$\begingroup\$ @Delta: the description clearly states "count the number of appearances ... in unary", so you can't just print the number directly. \$\endgroup\$ – randomdude999 Oct 21 at 14:41
  • \$\begingroup\$ @randomdude999 Thanks, my bad. \$\endgroup\$ – Delta Oct 21 at 14:43
1
\$\begingroup\$

Retina, 5 4 bytes

-1 byte thanks to @FryAmTheEggman

L` f

This creates the newline-separated list of all matches of the regex / f/.

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ You could use L and remove the last newline assuming that is still valid. The "falsy" requirement is sort of meaningless in Retina, unfortunately. \$\endgroup\$ – FryAmTheEggman Oct 21 at 15:03
1
\$\begingroup\$

WDC 65816 machine code, 22 bytes

Hex: A2 00 9B B5 00 C9 20 D0 07 B5 01 C9 66 D0 01 5A E8 B5 00 D0 EE DB

Disassembled:

    LDX #$00
    TXY
start:
    LDA $00,x
    CMP #$20 ; space
    BNE skip
    LDA $01,x
    CMP #$66 ; 'f'
    BNE skip
    PHY
skip:
    INX
    LDA $00,x
    BNE start
    STP

Assumes starting in 8-bit accumulator and index mode. (SEP #$30)

I/O format: input is a null-terminated string starting at the start of zero page. Output is null bytes on the actual stack. This seems to be allowed according to meta.

Try it online? Something as obscure as this isn't on TIO. This link is to a web interface of an IRC bot that has a command to assemble and execute 65816 code. (It uses the emulation from the bsnes SNES emulator, which is known for being very accurate.) All the LDA/STA at the start is just setting up the string in zero page. You can see the fact that stuff is being pushed by the stack register decreasing occasionally.

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

Japt, 4 bytes

èfù2

Try it

It's not entirely clear what exactly we should be outputting so this may need to be ...

ffù2

Try it

Or even ...

ffù2)ç

Try it

\$\endgroup\$
  • \$\begingroup\$ The first two are invalid, as we have to output a list of "falsy" values that cannot be " f". The fù2 is very clever though \$\endgroup\$ – Embodiment of Ignorance Oct 22 at 5:12
0
\$\begingroup\$

Japt v2.0a0 -Q, 7 bytes

f/ f/ ç

Try it

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

Perl 5, 8 bytes

say/ f/g

Try it online!

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

Keg, 18 10 bytes

?( =[f=[0.

Try it online!

-8 bytes thanks to @A_

Answer History

18 Bytes

?(!2/|``++`f `=[0.

Try it online!

\$\endgroup\$
  • \$\begingroup\$ 10 B \$\endgroup\$ – A _ Oct 22 at 14:07

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