Skip to main content
Commonmark migration
Source Link

#05AB1E,  44  50 44 bytes

05AB1E,  44  50 44 bytes

#05AB1E,  44  50 44 bytes

05AB1E,  44  50 44 bytes

deleted 133 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#05AB1E,  44  5050 44 bytes

[õ0U.µ["BFSH"3ÝΩ©è«®ĀX+U¼®X3/+3@¾Xµ["BFSH"3ÝΩ©è«®ĀX+U¼X2›®+3@¾X-3›~#}Dθ'FÊI¾Q*#I¾Q#

Port of @xnor's Python 2 answer, so make sure to upvote him as well if you like this answer!
+6 bytes due to a bug-fix. Will probably edit again, and after that -6 bytes again thanks to @xnor has fixed his Python answer, since I have the feelingby porting his fix will beway more efficient fix in terms of bytes thancomparison to my current fix.temporary work-around, as I was expecting. ;)

Try it onlineTry it online or verify some more random outputsverify some more random outputs.

[                # Start an infinite loop:
 õ               #  (Re)set the result-string to an empty string ""
 0U              #  (Re)set variable `X` to 0
 .µ              #  Reset the counter_variable to 0
   [             #  Start an inner infinite loop:
    "BFSH"       #   Push string "BFSH"
          3ÝΩ    #   Push a random integer in the range [0,3]
             ©   #   Store this random integer in variable `r` (without popping)
              è  #   Index it into the string "BFSH"
               « #   Append it to the result-string
    ®Ā           #   If `r` is NOT 0:
      X+U        #    Increase `X` by 1
    ¼            #   Increase the counter_variable by 1
    ®X3/+X2›®+        #   Calculate `X`/3`X`>2 (1 if truthy; 0 if falsey) + `r`
         3@      #   Check if this is larger than or equal to 3
    ¾X-          #   Calculate counter_variable - `X`
       3›        #   Check if this is larger than 3
    ~            #   If either of the two checks above is truhy:
     #           #    Stop the inner infinite loop
   }             #  After the inner infinite loop:
    Dθ'FÊ       '#  Check if the string does NOT end with an "F"
    I¾Q          #  Check ifIf the input and counter_variable are equal
         *       #  If both checks above are truthy:
       #   #      #   Stop the outer infinite loop
                 # (and output the result-string at the top of the stack implicitly)

#05AB1E,  44  50 bytes

[õ0U.µ["BFSH"3ÝΩ©è«®ĀX+U¼®X3/+3@¾X-3›~#}Dθ'FÊI¾Q*#

Port of @xnor's Python 2 answer, so make sure to upvote him as well if you like this answer!
+6 bytes due to a bug-fix. Will probably edit again after @xnor has fixed his Python answer, since I have the feeling his fix will be more efficient in terms of bytes than my current fix.. ;)

Try it online or verify some more random outputs.

[                # Start an infinite loop:
 õ               #  (Re)set the result-string to an empty string ""
 0U              #  (Re)set variable `X` to 0
 .µ              #  Reset the counter_variable to 0
   [             #  Start an inner infinite loop:
    "BFSH"       #   Push string "BFSH"
          3ÝΩ    #   Push a random integer in the range [0,3]
             ©   #   Store this random integer in variable `r` (without popping)
              è  #   Index it into the string "BFSH"
               « #   Append it to the result-string
    ®Ā           #   If `r` is NOT 0:
      X+U        #    Increase `X` by 1
    ¼            #   Increase the counter_variable by 1
    ®X3/+        #   Calculate `X`/3 + `r`
         3@      #   Check if this is larger than or equal to 3
    ¾X-          #   Calculate counter_variable - `X`
       3›        #   Check if this is larger than 3
    ~            #   If either of the two checks above is truhy:
     #           #    Stop the inner infinite loop
   }             #  After the inner infinite loop:
    Dθ'FÊ       '#  Check if the string does NOT end with an "F"
    I¾Q          #  Check if the input and counter_variable are equal
         *       #  If both checks above are truthy:
          #      #   Stop the outer infinite loop
                 # (and output the result-string at the top of the stack implicitly)

#05AB1E,  44  50 44 bytes

[õ0U.µ["BFSH"3ÝΩ©è«®ĀX+U¼X2›®+3@¾X-3›~#}I¾Q#

Port of @xnor's Python 2 answer, so make sure to upvote him as well if you like this answer!
+6 bytes due to a bug-fix, and after that -6 bytes again thanks to @xnor by porting his way more efficient fix in comparison to my temporary work-around, as I was expecting. ;)

Try it online or verify some more random outputs.

[                # Start an infinite loop:
 õ               #  (Re)set the result-string to an empty string ""
 0U              #  (Re)set variable `X` to 0
 .µ              #  Reset the counter_variable to 0
   [             #  Start an inner infinite loop:
    "BFSH"       #   Push string "BFSH"
          3ÝΩ    #   Push a random integer in the range [0,3]
             ©   #   Store this random integer in variable `r` (without popping)
              è  #   Index it into the string "BFSH"
               « #   Append it to the result-string
    ®Ā           #   If `r` is NOT 0:
      X+U        #    Increase `X` by 1
    ¼            #   Increase the counter_variable by 1
    X2›®+        #   Calculate `X`>2 (1 if truthy; 0 if falsey) + `r`
         3@      #   Check if this is larger than or equal to 3
    ¾X-          #   Calculate counter_variable - `X`
       3›        #   Check if this is larger than 3
    ~            #   If either of the two checks above is truhy:
     #           #    Stop the inner infinite loop
   }             #  After the inner infinite loop:
    I¾Q          #  If the input and counter_variable are equal:
       #         #   Stop the outer infinite loop
                 # (and output the result-string at the top of the stack implicitly)
added 532 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#05AB1E, 44 44  50 bytes

Crossed out  44  is no longer 44 :)

[õ0U.µ["BFSH"3ÝΩ©è«®ĀX+U¼®X3/+3@¾X-3›~#}I¾Q#Dθ'FÊI¾Q*#

Port of @xnor's Python 2 answer, so make sure to upvote him as well if you like this answer!
+6 bytes due to a bug-fix. Will probably edit again after @xnor has fixed his Python answer, since I have the feeling his fix will be more efficient in terms of bytes than my current fix.. ;)

Try it onlineTry it online or verify some more random outputsverify some more random outputs.

[                # Start an infinite loop:
 õ               #  (Re)set the result-string to an empty string ""
 0U              #  (Re)set variable `X` to 0
 .µ              #  Reset the counter_variable to 0
   [             #  Start an inner infinite loop:
    "BFSH"       #   Push string "BFSH"
          3ÝΩ    #   Push a random integer in the range [0,3]
             ©   #   Store this random integer in variable `r` (without popping)
              è  #   Index it into the string "BFSH"
               « #   Append it to the result-string
    ®Ā           #   If `r` is NOT 0:
      X+U        #    Increase `X` by 1
    ¼            #   Increase the counter_variable by 1
    ®X3/+        #   Calculate `X`/3 + `r`
         3@      #   Check if this is larger than or equal to 3
    ¾X-          #   Calculate counter_variable - `X`
       3›        #   Check if this is larger than 3
    ~            #   If either of the two checks above is truhy:
     #           #    Stop the inner infinite loop
   }             #  After the inner infinite loop:
    Dθ'FÊ       '#  Check if the string does NOT end with an "F"
    I¾Q          #  IfCheck if the input and counter_variable are equal:
         *       #  If both checks above are truthy:
          #      #   Stop the outer infinite loop
                 # (and output the result-string at the top of the stack implicitly)

#05AB1E, 44 bytes

[õ0U.µ["BFSH"3ÝΩ©è«®ĀX+U¼®X3/+3@¾X-3›~#}I¾Q#

Port of @xnor's Python 2 answer, so make sure to upvote him as well if you like this answer!

Try it online or verify some more random outputs.

[                # Start an infinite loop:
 õ               #  (Re)set the result-string to an empty string ""
 0U              #  (Re)set variable `X` to 0
 .µ              #  Reset the counter_variable to 0
   [             #  Start an inner infinite loop:
    "BFSH"       #   Push string "BFSH"
          3ÝΩ    #   Push a random integer in the range [0,3]
             ©   #   Store this random integer in variable `r` (without popping)
              è  #   Index it into the string "BFSH"
               « #   Append it to the result-string
    ®Ā           #   If `r` is NOT 0:
      X+U        #    Increase `X` by 1
    ¼            #   Increase the counter_variable by 1
    ®X3/+        #   Calculate `X`/3 + `r`
         3@      #   Check if this is larger than or equal to 3
    ¾X-          #   Calculate counter_variable - `X`
       3›        #   Check if this is larger than 3
    ~            #   If either of the two checks above is truhy:
     #           #    Stop the inner infinite loop
   }             #  After the inner infinite loop:
    I¾Q          #  If the input and counter_variable are equal:
       #         #   Stop the outer infinite loop
                 # (and output the result-string at the top of the stack implicitly)

#05AB1E,  44  50 bytes

Crossed out  44  is no longer 44 :)

[õ0U.µ["BFSH"3ÝΩ©è«®ĀX+U¼®X3/+3@¾X-3›~#}Dθ'FÊI¾Q*#

Port of @xnor's Python 2 answer, so make sure to upvote him as well if you like this answer!
+6 bytes due to a bug-fix. Will probably edit again after @xnor has fixed his Python answer, since I have the feeling his fix will be more efficient in terms of bytes than my current fix.. ;)

Try it online or verify some more random outputs.

[                # Start an infinite loop:
 õ               #  (Re)set the result-string to an empty string ""
 0U              #  (Re)set variable `X` to 0
 .µ              #  Reset the counter_variable to 0
   [             #  Start an inner infinite loop:
    "BFSH"       #   Push string "BFSH"
          3ÝΩ    #   Push a random integer in the range [0,3]
             ©   #   Store this random integer in variable `r` (without popping)
              è  #   Index it into the string "BFSH"
               « #   Append it to the result-string
    ®Ā           #   If `r` is NOT 0:
      X+U        #    Increase `X` by 1
    ¼            #   Increase the counter_variable by 1
    ®X3/+        #   Calculate `X`/3 + `r`
         3@      #   Check if this is larger than or equal to 3
    ¾X-          #   Calculate counter_variable - `X`
       3›        #   Check if this is larger than 3
    ~            #   If either of the two checks above is truhy:
     #           #    Stop the inner infinite loop
   }             #  After the inner infinite loop:
    Dθ'FÊ       '#  Check if the string does NOT end with an "F"
    I¾Q          #  Check if the input and counter_variable are equal
         *       #  If both checks above are truthy:
          #      #   Stop the outer infinite loop
                 # (and output the result-string at the top of the stack implicitly)
typos
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384
Loading
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384
Loading