Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Sandbox

Post History

71%
+3 −0
Sandbox Draw a line over ASCII

posted 4y ago by dzaima‭  ·  edited 3y ago by dzaima‭

#2: Post edited by user avatar dzaima‭ · 2021-04-18T00:29:34Z (over 3 years ago)
  • ## Challenge
  • Given a multiline string, list of lines, a character matrix or equivalent, and a description of a line, draw a line made out of either `'|'` or `'-'` over it.
  • The given text will consist of characters `" -|+"`. A `'-'` drawn over `'|'` or vice versa makes a `'+'`, and drawing over a `'+'` doesn't change it. All other combinations just override the previous character (that is, space is always overriden and drawing over an equal character doesn't change anything).
  • The information about the line can be any sufficient subset of:
  • - the starting position (location of the top-left-most character)
  • - the ending position (location of the bottom-right-most character)
  • - direction (i.e. horizontal or vertical, given as a boolean or numbers 0/1)
  • - length (can have a constant offset of ±1)
  • ## Examples
  • ```
  • All examples have the input text
  • " "
  • "-+--- "
  • " | --"
  • 1;0 → 4;0 (horizontal, length 4):
  • " ---- "
  • "-+--- "
  • " | --"
  • 4;0 → 4;1 (vertical, length 2):
  • " | "
  • "-+--+ "
  • " | --"
  • 1;0 → 1;2 (vertical, length 3):
  • " | "
  • "-+--- "
  • " | --"
  • 0;2 → 5;2 (horizontal, length 6):
  • " "
  • "-+--- "
  • "-+----"
  • ```
  • ## Notes
  • - The answer chooses which inputs are expected to be given.
  • - You are allowed to take redundant inputs (including requiring all).
  • - The coordinates can be taken as either 0-indexed or 1-indexed.
  • - The line will have a length of at least 2, ensuring that the start and end coordinates are always a sufficient description.
  • - The line will always need to be placed in the bounds of the input.
  • - If applicable, the solution can mutate the input text instead of outputting a modified version.
  • - Shortest answer per language, scored in bytes, wins!
  • ## Challenge
  • Given a multiline string, list of lines, a character matrix or equivalent, and a description of a line, draw a line made out of either `'|'` or `'-'` over it.
  • The given text will consist of characters `" -|+"`. A `'-'` drawn over `'|'` or vice versa makes a `'+'`, and drawing over a `'+'` doesn't change it. All other combinations just override the previous character (that is, space is always overridden and drawing over an equal character doesn't change anything).
  • You can choose what information about the location of the line you will receive, from these options:
  • - the starting position (location of the top-left-most character)
  • - the ending position (location of the bottom-right-most character)
  • - direction (i.e. horizontal or vertical, given as a boolean or numbers 0/1; which is which doesn't matter)
  • - length (can have a constant offset of ±1)
  • ## Examples
  • ```
  • All examples have the input text
  • " "
  • "-+--- "
  • " | --"
  • 1;0 → 4;0 (horizontal, length 4):
  • " ---- "
  • "-+--- "
  • " | --"
  • 4;0 → 4;1 (vertical, length 2):
  • " | "
  • "-+--+ "
  • " | --"
  • 1;0 → 1;2 (vertical, length 3):
  • " | "
  • "-+--- "
  • " | --"
  • 0;2 → 5;2 (horizontal, length 6):
  • " "
  • "-+--- "
  • "-+----"
  • ```
  • ## Notes
  • - The answer chooses which inputs are expected to be given (including redundant ones), so has to handle only one case.
  • - The coordinates can be taken as either 0-indexed or 1-indexed.
  • - The line will have a length of at least 2, ensuring that the start and end coordinates are always a sufficient description.
  • - The line will always need to be placed in the bounds of the input.
  • - If applicable, the solution can mutate the input text instead of outputting/returning a modified version.
  • - Shortest answer per language, scored in bytes, wins!
#1: Initial revision by user avatar dzaima‭ · 2020-12-08T13:27:30Z (about 4 years ago)
Draw a line over ASCII
## Challenge

Given a multiline string, list of lines, a character matrix or equivalent, and a description of a line, draw a line made out of either `'|'` or `'-'` over it.

The given text will consist of characters `" -|+"`. A `'-'` drawn over `'|'` or vice versa makes a `'+'`, and drawing over a `'+'` doesn't change it. All other combinations just override the previous character (that is, space is always overriden and drawing over an equal character doesn't change anything).

The information about the line can be any sufficient subset of:

- the starting position (location of the top-left-most character)
- the ending position (location of the bottom-right-most character)
- direction (i.e. horizontal or vertical, given as a boolean or numbers 0/1)
- length (can have a constant offset of ±1)


## Examples

```
All examples have the input text
"      "
"-+--- "
" |  --"

1;0 → 4;0 (horizontal, length 4):
" ---- "
"-+--- "
" |  --"
4;0 → 4;1 (vertical, length 2):
"    | "
"-+--+ "
" |  --"
1;0 → 1;2 (vertical, length 3):
" |    "
"-+--- "
" |  --"
0;2 → 5;2 (horizontal, length 6):
"      "
"-+--- "
"-+----"
```

## Notes

- The answer chooses which inputs are expected to be given.
- You are allowed to take redundant inputs (including requiring all).
- The coordinates can be taken as either 0-indexed or 1-indexed.
- The line will have a length of at least 2, ensuring that the start and end coordinates are always a sufficient description.
- The line will always need to be placed in the bounds of the input.
- If applicable, the solution can mutate the input text instead of outputting a modified version.
- Shortest answer per language, scored in bytes, wins!