Skip to main content
added 56 characters in body
Source Link
Xcali
  • 16.2k
  • 2
  • 15
  • 39

Perl 5, 130130 126 bytes

128124 bytes of code + 2 for -ap flags

push@a,[map 0|$_/10,@F]}{map{$_=say map{($a[$r+1][$c]-$_&&$r<$#a?'_':$").($a[$r][++$c]-$_&&$c<@{$a[0]}?'|':$")for@$_;$c=0;$r++;say@$_}@$_;$c=0;$r++}@a

Try it online!Try it online!

Input format is 2-D grid of space separated numbers.

Explanation

This is from a previous iteration of the code.

push@a,[map 0|$_/10,@F]     # read the input, divide it by 10, and store it in a 2-D array
}{                          # end the implicit while loop and start the final block
map{                        # repeat this for each line
  $_=($a[$r+1][$c]-$_&&$r<$#a?'_':$")       # set appropriate characters to output based
     .($a[$r][++$c]-$_&&$c<@{$a[0]}?'|':$") # on the given rules
  for@$_;                                   # repeat for each number on the line
  $c=0;$r++;                         # setup row and column counters for next iteration
  say@$_                             # output this line
}@a

Perl 5, 130 bytes

128 bytes of code + 2 for -ap flags

push@a,[map 0|$_/10,@F]}{map{$_=($a[$r+1][$c]-$_&&$r<$#a?'_':$").($a[$r][++$c]-$_&&$c<@{$a[0]}?'|':$")for@$_;$c=0;$r++;say@$_}@a

Try it online!

Input format is 2-D grid of space separated numbers.

Explanation

push@a,[map 0|$_/10,@F]     # read the input, divide it by 10, and store it in a 2-D array
}{                          # end the implicit while loop and start the final block
map{                        # repeat this for each line
  $_=($a[$r+1][$c]-$_&&$r<$#a?'_':$")       # set appropriate characters to output based
     .($a[$r][++$c]-$_&&$c<@{$a[0]}?'|':$") # on the given rules
  for@$_;                                   # repeat for each number on the line
  $c=0;$r++;                         # setup row and column counters for next iteration
  say@$_                             # output this line
}@a

Perl 5, 130 126 bytes

124 bytes of code + 2 for -ap flags

push@a,[map 0|$_/10,@F]}{map{say map{($a[$r+1][$c]-$_&&$r<$#a?'_':$").($a[$r][++$c]-$_&&$c<@{$a[0]}?'|':$")}@$_;$c=0;$r++}@a

Try it online!

Input format is 2-D grid of space separated numbers.

Explanation

This is from a previous iteration of the code.

push@a,[map 0|$_/10,@F]     # read the input, divide it by 10, and store it in a 2-D array
}{                          # end the implicit while loop and start the final block
map{                        # repeat this for each line
  $_=($a[$r+1][$c]-$_&&$r<$#a?'_':$")       # set appropriate characters to output based
     .($a[$r][++$c]-$_&&$c<@{$a[0]}?'|':$") # on the given rules
  for@$_;                                   # repeat for each number on the line
  $c=0;$r++;                         # setup row and column counters for next iteration
  say@$_                             # output this line
}@a
deleted 12 characters in body
Source Link
Xcali
  • 16.2k
  • 2
  • 15
  • 39

Perl 5, 134130 bytes

132128 bytes of code + 2 for -ap flags

push@a,[map$_=int$_[map 0|$_/10,@F]}{map{$\.=$_=($a[$r+1][$c]==$_||$r>=$#a$a[$r+1][$c]-$_&&$r<$#a?$":'_':$").($a[$r][++$c]==$_||$c==$#$_$a[$r][++$c]-$_&&$c<@{$a[0]}?$":'|':$")for@$_;$c=0;$r++;$\.=$/for@$_;$c=0;$r++;say@$_}@a

Try it online!Try it online!

Input format is 2-D grid of space separated numbers.

Explanation

push@a,[map$_=int$_[map 0|$_/10,@F]     # read the input, divide it by 10, and store it in a 2-D array
}{                          # end the implicit while loop and start the final block
map{                        # repeat this for each line
  $\.=$_=($a[$r+1][$c]==$_||$r>=$#a$a[$r+1][$c]-$_&&$r<$#a?$":'_':$")       # appendset appropriate charactercharacters to output based on
     .($a[$r][++$c]==$_||$c==$#$_$a[$r][++$c]-$_&&$c<@{$a[0]}?$":'|':$") # on the given rules
  for@$_;                                   # repeat for each number on the line
  $c=0;$r++;                         # setup row and column counters for next iteration
  $\.=$/say@$_                             # put a newline inoutput thethis outputline
}@a

Perl 5, 134 bytes

132 bytes of code + 2 for -ap

push@a,[map$_=int$_/10,@F]}{map{$\.=($a[$r+1][$c]==$_||$r>=$#a?$":'_').($a[$r][++$c]==$_||$c==$#$_?$":'|')for@$_;$c=0;$r++;$\.=$/}@a

Try it online!

Input format is 2-D grid of space separated numbers.

Explanation

push@a,[map$_=int$_/10,@F]  # read the input, divide it by 10, and store it in a 2-D array
}{                          # end the implicit while loop and start the final block
map{                        # repeat this for each line
  $\.=($a[$r+1][$c]==$_||$r>=$#a?$":'_')  # append appropriate character to output based on
     .($a[$r][++$c]==$_||$c==$#$_?$":'|') # the given rules
  for@$_;                                 # repeat for each number on the line
  $c=0;$r++;                         # setup row and column counters for next iteration
  $\.=$/                             # put a newline in the output
}@a

Perl 5, 130 bytes

128 bytes of code + 2 for -ap flags

push@a,[map 0|$_/10,@F]}{map{$_=($a[$r+1][$c]-$_&&$r<$#a?'_':$").($a[$r][++$c]-$_&&$c<@{$a[0]}?'|':$")for@$_;$c=0;$r++;say@$_}@a

Try it online!

Input format is 2-D grid of space separated numbers.

Explanation

push@a,[map 0|$_/10,@F]     # read the input, divide it by 10, and store it in a 2-D array
}{                          # end the implicit while loop and start the final block
map{                        # repeat this for each line
  $_=($a[$r+1][$c]-$_&&$r<$#a?'_':$")       # set appropriate characters to output based
     .($a[$r][++$c]-$_&&$c<@{$a[0]}?'|':$") # on the given rules
  for@$_;                                   # repeat for each number on the line
  $c=0;$r++;                         # setup row and column counters for next iteration
  say@$_                             # output this line
}@a
added 691 characters in body
Source Link
Xcali
  • 16.2k
  • 2
  • 15
  • 39

Perl 5, 134 bytes

132 bytes of code + 2 for -ap

push@a,[map$_=int$_/10,@F]}{map{$\.=($a[$r+1][$c]==$_||$r>=$#a?$":'_').($a[$r][++$c]==$_||$c==$#$_?$":'|')for@$_;$c=0;$r++;$\.=$/}@a

Try it online!

Input format is 2-D grid of space separated numbers.

Explanation

push@a,[map$_=int$_/10,@F]  # read the input, divide it by 10, and store it in a 2-D array
}{                          # end the implicit while loop and start the final block
map{                        # repeat this for each line
  $\.=($a[$r+1][$c]==$_||$r>=$#a?$":'_')  # append appropriate character to output based on
     .($a[$r][++$c]==$_||$c==$#$_?$":'|') # the given rules
  for@$_;                                 # repeat for each number on the line
  $c=0;$r++;                         # setup row and column counters for next iteration
  $\.=$/                             # put a newline in the output
}@a

Perl 5, 134 bytes

132 bytes of code + 2 for -ap

push@a,[map$_=int$_/10,@F]}{map{$\.=($a[$r+1][$c]==$_||$r>=$#a?$":'_').($a[$r][++$c]==$_||$c==$#$_?$":'|')for@$_;$c=0;$r++;$\.=$/}@a

Try it online!

Input format is 2-D grid of space separated numbers.

Perl 5, 134 bytes

132 bytes of code + 2 for -ap

push@a,[map$_=int$_/10,@F]}{map{$\.=($a[$r+1][$c]==$_||$r>=$#a?$":'_').($a[$r][++$c]==$_||$c==$#$_?$":'|')for@$_;$c=0;$r++;$\.=$/}@a

Try it online!

Input format is 2-D grid of space separated numbers.

Explanation

push@a,[map$_=int$_/10,@F]  # read the input, divide it by 10, and store it in a 2-D array
}{                          # end the implicit while loop and start the final block
map{                        # repeat this for each line
  $\.=($a[$r+1][$c]==$_||$r>=$#a?$":'_')  # append appropriate character to output based on
     .($a[$r][++$c]==$_||$c==$#$_?$":'|') # the given rules
  for@$_;                                 # repeat for each number on the line
  $c=0;$r++;                         # setup row and column counters for next iteration
  $\.=$/                             # put a newline in the output
}@a
Source Link
Xcali
  • 16.2k
  • 2
  • 15
  • 39
Loading