Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

deleted 7 characters in body
Source Link
Sp3000
  • 62.2k
  • 13
  • 117
  • 292

Half-Broken Car in Heavy Traffic, 9 + 3 = 12 bytes

#<
o^<
 v

Half-Broken Car in Heavy Traffic (HBCHT) takes input as command line args, so run like

py -3 hbcht cat.hbc -s "candy corn"

Note that the +3 is for the -s flag, which outputs as chars.

Note that Also, HBCHT doesn't seem handle NULs, as all zeroes are dropped from the output (e.g. 97 0 98 is output as two chars ab).

Explanation

In HBCHT, your car starts at the o and your goal is the exit #. ^>v< direct the car's movement, while simultaneously modifying a BF-like tape (^>v< translate to +>-<). However, as the language name suggests, your car can only turn right – any attempts to turn left are ignored completely (including their memory effects). Note that this is only for turning – your car is perfectly capable of driving forward/reversing direction.

Other interesting parts about HBCHT are that your car's initial direction is randomised, and the grid is toroidal. Thus we just need the car to make it to the exit without modifying the tape for all four initial directions:

  • Up and down are straightforward, heading directly to the exit.

  • For left, we wrap and execute < and increment with ^. We can't turn left at the next < so we wrap and decrement with v, negating out previous increment. Since we're heading downwards now we can turn right at the < and exit, having moved the pointer twice and modifying no cell values.

  • For right, we do the same thing as left but skip the first ^ since we can't turn left.


Edit: It turns out that the HBCHT interpreter does let you execute just a single path via a command line flag, e.g.

py -3 hbcht -d left cat.hbc

However, not only is the flag too expensive for this particular question (at least 5 bytes for " -d u"), it seems that all paths still need to be able to make it to the exit for the code to execute.

Half-Broken Car in Heavy Traffic, 9 + 3 = 12 bytes

#<
o^<
 v

Half-Broken Car in Heavy Traffic (HBCHT) takes input as command line args, so run like

py -3 hbcht cat.hbc -s "candy corn"

Note that the +3 is for the -s flag, which outputs as chars.

Note that HBCHT doesn't seem handle NULs, as all zeroes are dropped from the output (e.g. 97 0 98 is output as two chars ab).

Explanation

In HBCHT, your car starts at the o and your goal is the exit #. ^>v< direct the car's movement, while simultaneously modifying a BF-like tape (^>v< translate to +>-<). However, as the language name suggests, your car can only turn right – any attempts to turn left are ignored completely (including their memory effects). Note that this is only for turning – your car is perfectly capable of driving forward/reversing direction.

Other interesting parts about HBCHT are that your car's initial direction is randomised, and the grid is toroidal. Thus we just need the car to make it to the exit without modifying the tape for all four initial directions:

  • Up and down are straightforward, heading directly to the exit.

  • For left, we wrap and execute < and increment with ^. We can't turn left at the next < so we wrap and decrement with v, negating out previous increment. Since we're heading downwards now we can turn right at the < and exit, having moved the pointer twice and modifying no cell values.

  • For right, we do the same thing as left but skip the first ^ since we can't turn left.


Edit: It turns out that the HBCHT interpreter does let you execute just a single path via a command line flag, e.g.

py -3 hbcht -d left cat.hbc

However, not only is the flag too expensive for this particular question (at least 5 bytes for " -d u"), it seems that all paths still need to be able to make it to the exit for the code to execute.

Half-Broken Car in Heavy Traffic, 9 + 3 = 12 bytes

#<
o^<
 v

Half-Broken Car in Heavy Traffic (HBCHT) takes input as command line args, so run like

py -3 hbcht cat.hbc -s "candy corn"

Note that the +3 is for the -s flag, which outputs as chars. Also, HBCHT doesn't seem handle NULs, as all zeroes are dropped from the output (e.g. 97 0 98 is output as two chars ab).

Explanation

In HBCHT, your car starts at the o and your goal is the exit #. ^>v< direct the car's movement, while simultaneously modifying a BF-like tape (^>v< translate to +>-<). However, as the language name suggests, your car can only turn right – any attempts to turn left are ignored completely (including their memory effects). Note that this is only for turning – your car is perfectly capable of driving forward/reversing direction.

Other interesting parts about HBCHT are that your car's initial direction is randomised, and the grid is toroidal. Thus we just need the car to make it to the exit without modifying the tape for all four initial directions:

  • Up and down are straightforward, heading directly to the exit.

  • For left, we wrap and execute < and increment with ^. We can't turn left at the next < so we wrap and decrement with v, negating out previous increment. Since we're heading downwards now we can turn right at the < and exit, having moved the pointer twice and modifying no cell values.

  • For right, we do the same thing as left but skip the first ^ since we can't turn left.


Edit: It turns out that the HBCHT interpreter does let you execute just a single path via a command line flag, e.g.

py -3 hbcht -d left cat.hbc

However, not only is the flag too expensive for this particular question (at least 5 bytes for " -d u"), it seems that all paths still need to be able to make it to the exit for the code to execute.

deleted 1 character in body
Source Link
Sp3000
  • 62.2k
  • 13
  • 117
  • 292

Half-Broken Car in Heavy Traffic, 189 + 3 = 12 bytes

@outtext
#<
o^<
 v

Half-Broken Car in Heavy Traffic (HBCHT) takes input as command line args, so run like

py -3 hbcht cat.hbchthbc -s "candy corn"

If it wasn'tNote that the +3 is for the char input/output-s flag, we could have 9 bytes by removing the first line and doing the following instead:which outputs as chars.

py -3 hbcht cat.hbcht 99 97 116

Note that HBCHT doesn't seem handle NULs, as all zeroes are dropped from the output (e.g. 97 0 98 is output as two chars ab).

Explanation

In HBCHT, your car starts at the o and your goal is the exit #. ^>v< direct the car's movement, while simultaneously modifying a BF-like tape (^>v< translate to +>-<). However, as the language name suggests, your car can only turn right – any attempts to turn left are ignored completely (including their memory effects). Note that this is only for turning – your car is perfectly capable of driving forward/reversing direction.

Other interesting parts about HBCHT are that your car's initial direction is randomised, and the grid is toroidal. Thus we just need the car to make it to the exit without modifying the tape for all four initial directions:

  • Up and down are straightforward, heading directly to the exit (the @outtext isn't part of the grid – it just signifies that we want char output).

  • For left, we wrap and execute < and increment with ^. We can't turn left at the next < so we wrap and decrement with v, negating out previous increment. Since we're heading downwards now we can turn right at the < and exit, having moved the pointer twice and modifying no cell values.

  • For right, we do the same thing as left but skip the first ^ since we can't turn left.


Edit: It turns out that the HBCHT interpreter does let you execute just a single path via a command line flag, e.g.

py -3 hbcht -d left cat.hbchthbc

However, not only is the flag too expensive for this particular question (at least 65 bytes for " -d up"u"), it seems that all paths still need to be able to make it to the exit for the code to execute.

Half-Broken Car in Heavy Traffic, 18 bytes

@outtext
#<
o^<
 v

Half-Broken Car in Heavy Traffic (HBCHT) takes input as command line args, so run like

py -3 hbcht cat.hbcht "candy corn"

If it wasn't for the char input/output, we could have 9 bytes by removing the first line and doing the following instead:

py -3 hbcht cat.hbcht 99 97 116

Note that HBCHT doesn't seem handle NULs, as all zeroes are dropped from the output (e.g. 97 0 98 is output as two chars ab).

Explanation

In HBCHT, your car starts at the o and your goal is the exit #. ^>v< direct the car's movement, while simultaneously modifying a BF-like tape (^>v< translate to +>-<). However, as the language name suggests, your car can only turn right – any attempts to turn left are ignored completely (including their memory effects). Note that this is only for turning – your car is perfectly capable of driving forward/reversing direction.

Other interesting parts about HBCHT are that your car's initial direction is randomised, and the grid is toroidal. Thus we just need the car to make it to the exit without modifying the tape for all four initial directions:

  • Up and down are straightforward, heading directly to the exit (the @outtext isn't part of the grid – it just signifies that we want char output).

  • For left, we wrap and execute < and increment with ^. We can't turn left at the next < so we wrap and decrement with v, negating out previous increment. Since we're heading downwards now we can turn right at the < and exit, having moved the pointer twice and modifying no cell values.

  • For right, we do the same thing as left but skip the first ^ since we can't turn left.


Edit: It turns out that the HBCHT interpreter does let you execute just a single path via a command line flag, e.g.

py -3 hbcht -d left cat.hbcht

However, not only is the flag too expensive for this particular question (at least 6 bytes for " -d up"), it seems that all paths still need to be able to make it to the exit for the code to execute.

Half-Broken Car in Heavy Traffic, 9 + 3 = 12 bytes

#<
o^<
 v

Half-Broken Car in Heavy Traffic (HBCHT) takes input as command line args, so run like

py -3 hbcht cat.hbc -s "candy corn"

Note that the +3 is for the -s flag, which outputs as chars.

Note that HBCHT doesn't seem handle NULs, as all zeroes are dropped from the output (e.g. 97 0 98 is output as two chars ab).

Explanation

In HBCHT, your car starts at the o and your goal is the exit #. ^>v< direct the car's movement, while simultaneously modifying a BF-like tape (^>v< translate to +>-<). However, as the language name suggests, your car can only turn right – any attempts to turn left are ignored completely (including their memory effects). Note that this is only for turning – your car is perfectly capable of driving forward/reversing direction.

Other interesting parts about HBCHT are that your car's initial direction is randomised, and the grid is toroidal. Thus we just need the car to make it to the exit without modifying the tape for all four initial directions:

  • Up and down are straightforward, heading directly to the exit.

  • For left, we wrap and execute < and increment with ^. We can't turn left at the next < so we wrap and decrement with v, negating out previous increment. Since we're heading downwards now we can turn right at the < and exit, having moved the pointer twice and modifying no cell values.

  • For right, we do the same thing as left but skip the first ^ since we can't turn left.


Edit: It turns out that the HBCHT interpreter does let you execute just a single path via a command line flag, e.g.

py -3 hbcht -d left cat.hbc

However, not only is the flag too expensive for this particular question (at least 5 bytes for " -d u"), it seems that all paths still need to be able to make it to the exit for the code to execute.

added 519 characters in body
Source Link
Sp3000
  • 62.2k
  • 13
  • 117
  • 292

Half-Broken Car in Heavy Traffic, 18 bytes

@outtext
#<
o^<
 v

Half-Broken Car in Heavy Traffic (HBCHT) takes input as command line args, so run like

py -3 hbcht cat.hbcht "candy corn"

If it wasn't for the char input/output, we could have 9 bytes by removing the first line and doing the following instead:

py -3 hbcht cat.hbcht 99 97 116

Note that HBCHT doesn't seem handle NULs, as all zeroes are dropped from the output (e.g. 97 0 98 is output as two chars ab).

Explanation

In HBCHT, your car starts at the o and your goal is the exit #. ^>v< direct the car's movement, while simultaneously modifying a BF-like tape (^>v< translate to +>-<). However, as the language name suggests, your car can only turn right – any attempts to turn left are ignored completely (including their memory effects). Note that this is only for turning – your car is perfectly capable of driving forward/reversing direction.

Other interesting parts about HBCHT are that your car's initial direction is randomised, and the grid is toroidal. Thus we just need the car to make it to the exit without modifying the tape for all four initial directions:

  • Up and down are straightforward, heading directly to the exit (the @outtext isn't part of the grid – it just signifies that we want char output).

  • For left, we wrap and execute < and increment with ^. We can't turn left at the next < so we wrap and decrement with v, negating out previous increment. Since we're heading downwards now we can turn right at the < and exit, having moved the pointer twice and modifying no cell values.

  • For right, we do the same thing as left but skip the first ^ since we can't turn left.


Edit: It turns out that the HBCHT interpreter does let you execute just a single path via a command line flag, e.g.

py -3 hbcht -d left cat.hbcht

However, not only is the flag too expensive for this particular question (at least 6 bytes for " -d up"), it seems that all paths still need to be able to make it to the exit for the code to execute.

Half-Broken Car in Heavy Traffic, 18 bytes

@outtext
#<
o^<
 v

Half-Broken Car in Heavy Traffic (HBCHT) takes input as command line args, so run like

py -3 hbcht "candy corn"

If it wasn't for the char input/output, we could have 9 bytes by removing the first line and doing the following instead:

py -3 hbcht 99 97 116

Explanation

In HBCHT, your car starts at the o and your goal is the exit #. ^>v< direct the car's movement, while simultaneously modifying a BF-like tape (^>v< translate to +>-<). However, as the language name suggests, your car can only turn right – any attempts to turn left are ignored completely (including their memory effects). Note that this is only for turning – your car is perfectly capable of driving forward/reversing direction.

Other interesting parts about HBCHT are that your car's initial direction is randomised, and the grid is toroidal. Thus we just need the car to make it to the exit without modifying the tape for all four initial directions:

  • Up and down are straightforward, heading directly to the exit (the @outtext isn't part of the grid – it just signifies that we want char output).

  • For left, we wrap and execute < and increment with ^. We can't turn left at the next < so we wrap and decrement with v, negating out previous increment. Since we're heading downwards now we can turn right at the < and exit, having moved the pointer twice and modifying no cell values.

  • For right, we do the same thing as left but skip the first ^ since we can't turn left.

Half-Broken Car in Heavy Traffic, 18 bytes

@outtext
#<
o^<
 v

Half-Broken Car in Heavy Traffic (HBCHT) takes input as command line args, so run like

py -3 hbcht cat.hbcht "candy corn"

If it wasn't for the char input/output, we could have 9 bytes by removing the first line and doing the following instead:

py -3 hbcht cat.hbcht 99 97 116

Note that HBCHT doesn't seem handle NULs, as all zeroes are dropped from the output (e.g. 97 0 98 is output as two chars ab).

Explanation

In HBCHT, your car starts at the o and your goal is the exit #. ^>v< direct the car's movement, while simultaneously modifying a BF-like tape (^>v< translate to +>-<). However, as the language name suggests, your car can only turn right – any attempts to turn left are ignored completely (including their memory effects). Note that this is only for turning – your car is perfectly capable of driving forward/reversing direction.

Other interesting parts about HBCHT are that your car's initial direction is randomised, and the grid is toroidal. Thus we just need the car to make it to the exit without modifying the tape for all four initial directions:

  • Up and down are straightforward, heading directly to the exit (the @outtext isn't part of the grid – it just signifies that we want char output).

  • For left, we wrap and execute < and increment with ^. We can't turn left at the next < so we wrap and decrement with v, negating out previous increment. Since we're heading downwards now we can turn right at the < and exit, having moved the pointer twice and modifying no cell values.

  • For right, we do the same thing as left but skip the first ^ since we can't turn left.


Edit: It turns out that the HBCHT interpreter does let you execute just a single path via a command line flag, e.g.

py -3 hbcht -d left cat.hbcht

However, not only is the flag too expensive for this particular question (at least 6 bytes for " -d up"), it seems that all paths still need to be able to make it to the exit for the code to execute.

Source Link
Sp3000
  • 62.2k
  • 13
  • 117
  • 292
Loading

AltStyle によって変換されたページ (->オリジナル) /