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

Bugfix (Find should have been Count)
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Charcoal, (削除) 29 (削除ここまで) (削除) 27 (削除ここまで) (削除) 20 (削除ここまで) 19 bytes

FS«F⌕rdlu↧ι≔ιω✳∨ωrιFS«FNordlu↧ι≔ιω✳∨ωrι

Try it online! Try it online! Link is to verbose version of code. Explanation:

FS«

Loop over the input characters.

F⌕rdlu↧ιFNordlu↧ι

If the current letter is a direction...

≔ιω

then update the current walking direction.

✳∨ωrι

Print the character in the current walking direction, defaulting to right if no direction has been set yet.

Charcoal, (削除) 29 (削除ここまで) (削除) 27 (削除ここまで) (削除) 20 (削除ここまで) 19 bytes

FS«F⌕rdlu↧ι≔ιω✳∨ωrι

Try it online! Link is to verbose version of code. Explanation:

FS«

Loop over the input characters.

F⌕rdlu↧ι

If the current letter is a direction...

≔ιω

then update the current walking direction.

✳∨ωrι

Print the character in the current walking direction, defaulting to right if no direction has been set yet.

Charcoal, (削除) 29 (削除ここまで) (削除) 27 (削除ここまで) (削除) 20 (削除ここまで) 19 bytes

FS«FNordlu↧ι≔ιω✳∨ωrι

Try it online! Link is to verbose version of code. Explanation:

FS«

Loop over the input characters.

FNordlu↧ι

If the current letter is a direction...

≔ιω

then update the current walking direction.

✳∨ωrι

Print the character in the current walking direction, defaulting to right if no direction has been set yet.

added 2 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Charcoal, (削除) 29 (削除ここまで) (削除) 27 (削除ここまで) 20(削除) 20 (削除ここまで) 19 bytes

≔rθFS«F⌕rdlu↧ι≔ιθ✳θιFS«F⌕rdlu↧ι≔ιω✳∨ωrι

Try it online! Try it online! Link is to verbose version of code. Explanation:

≔rθ

Initialise the walking direction to horizontal.

FS«

Loop over the input characters.

F⌕rdlu↧ι

If the current letter is a direction...

≔ιθ≔ιω

then update the current walking direction.

✳θι✳∨ωrι

Print the character in the current walking direction, defaulting to right if no direction has been set yet.

Charcoal, (削除) 29 (削除ここまで) (削除) 27 (削除ここまで) 20 bytes

≔rθFS«F⌕rdlu↧ι≔ιθ✳θι

Try it online! Link is to verbose version of code. Explanation:

≔rθ

Initialise the walking direction to horizontal.

FS«

Loop over the input characters.

F⌕rdlu↧ι

If the current letter is a direction...

≔ιθ

then update the current walking direction.

✳θι

Print the character in the current walking direction.

Charcoal, (削除) 29 (削除ここまで) (削除) 27 (削除ここまで) (削除) 20 (削除ここまで) 19 bytes

FS«F⌕rdlu↧ι≔ιω✳∨ωrι

Try it online! Link is to verbose version of code. Explanation:

FS«

Loop over the input characters.

F⌕rdlu↧ι

If the current letter is a direction...

≔ιω

then update the current walking direction.

✳∨ωrι

Print the character in the current walking direction, defaulting to right if no direction has been set yet.

added 139 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Charcoal, (削除) 29 (削除ここまで) 27(削除) 27 (削除ここまで) 20 bytes

≔⊟⟦→⟧θFS«≔§⟦+✳θ⟧⌕rdlu↧ιθ✳θι≔rθFS«F⌕rdlu↧ι≔ιθ✳θι

Try it online! Try it online! Link is to verbose version of code. Explanation:

≔⊟⟦→⟧θ≔rθ

Initialise the walking direction to horizontal.

FS«

Loop over the input characters.

≔§⟦+✳θ⟧⌕rdlu↧ιθF⌕rdlu↧ι

Index into the new direction using the index ofIf the current lowercase letter in the string rdluis a direction. If it matches,..

≔ιθ

then take the direction automatically expanded from + into the four directions, otherwise default toupdate the current walking direction.

✳θι

Print the character in the current walking direction.

Charcoal, (削除) 29 (削除ここまで) 27 bytes

≔⊟⟦→⟧θFS«≔§⟦+✳θ⟧⌕rdlu↧ιθ✳θι

Try it online! Link is to verbose version of code. Explanation:

≔⊟⟦→⟧θ

Initialise the walking direction to horizontal.

FS«

Loop over the input characters.

≔§⟦+✳θ⟧⌕rdlu↧ιθ

Index into the new direction using the index of the current lowercase letter in the string rdlu. If it matches, then take the direction automatically expanded from + into the four directions, otherwise default to the current direction.

✳θι

Print the character in the current walking direction.

Charcoal, (削除) 29 (削除ここまで) (削除) 27 (削除ここまで) 20 bytes

≔rθFS«F⌕rdlu↧ι≔ιθ✳θι

Try it online! Link is to verbose version of code. Explanation:

≔rθ

Initialise the walking direction to horizontal.

FS«

Loop over the input characters.

F⌕rdlu↧ι

If the current letter is a direction...

≔ιθ

then update the current walking direction.

✳θι

Print the character in the current walking direction.

added 139 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290
Loading
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290
Loading

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