Skip to main content
improved algorythm
Source Link
pajonk
  • 18.3k
  • 3
  • 26
  • 74

Matlab, 74 71 6262 57 bytes

@(s)[s(1:end-1) [0' 46]+.'+(s(1)>46)*[47 46]+*'/.'+(s(end)>47)*[45 -45]]

It computes the last two characters based on the s(1) (first character) - to determine if we're dealing with the \/ case, and the last character s(end) to make the correct tuple for the \/ characters.

Matlab, 74 71 62 bytes

@(s)[s(1:end-1) [0 46]+(s(1)>46)*[47 46]+(s(end)>47)*[45 -45]]

It computes the last two characters based on the s(1) (first character) - to determine if we're dealing with the \/ case, and the last character s(end) to make the correct tuple for the \/ characters.

Matlab, 74 71 62 57 bytes

@(s)[s(1:end-1) ' .'+(s(1)>46)*'/.'+(s(end)>47)*[45 -45]]

It computes the last two characters based on the s(1) (first character) - to determine if we're dealing with the \/ case, and the last character s(end) to make the correct tuple for the \/ characters.

added 146 characters in body
Source Link
pajonk
  • 18.3k
  • 3
  • 26
  • 74

Matlab, 74 7171 62 bytes

s=input('');x=s@(ends);[s[s(1:end-1) [0 46]+(x>46s(1)>46)*[47 46]+(x>47s(end)>47)*[45 -45]]

Based onIt computes the last two characters based on the s(1) (first character) - to determine if we're dealing with the \/ case, it computesand the last twocharacter s(end) to make the correct tuple for the \/ characters.

Matlab, 74 71 bytes

s=input('');x=s(end);[s(1:end-1) [0 46]+(x>46)*[47 46]+(x>47)*[45 -45]]

Based on the last character, it computes the last two characters.

Matlab, 74 71 62 bytes

@(s)[s(1:end-1) [0 46]+(s(1)>46)*[47 46]+(s(end)>47)*[45 -45]]

It computes the last two characters based on the s(1) (first character) - to determine if we're dealing with the \/ case, and the last character s(end) to make the correct tuple for the \/ characters.

improved algorythm
Source Link
pajonk
  • 18.3k
  • 3
  • 26
  • 74

Matlab, 7574 71 bytes

s=input('');x=s(end);[s(1:end-1) [0 46]+(x>46)*[x*[47 92]-46]+(x>47)*[0 45]+(x<47)*[0*[45 x]]-45]]

Based on the last character, it computes the last two characters.

Matlab, 75 bytes

s=input('');x=s(end);[s(1:end-1) (x>46)*[x 92]-(x>47)*[0 45]+(x<47)*[0 x]]

Based on the last character, it computes the last two characters.

Matlab, 74 71 bytes

s=input('');x=s(end);[s(1:end-1) [0 46]+(x>46)*[47 46]+(x>47)*[45 -45]]

Based on the last character, it computes the last two characters.

Source Link
pajonk
  • 18.3k
  • 3
  • 26
  • 74
Loading