You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was not able to think of a straightforward solution that works on negative integers. Probably my solution for problem no. 2 (#11) affected my thinking in a negative way.
⍝ arrToInt needs to start at index zero since the use of 10*0 in units⎕IO←0⍝ the range in which acceptable values existrange← (¯2*31) (1-⍨2*31)
⍝ if in range return the number, zero otherwiseinRange← {⍵×≠/range<⍵}
⍝ convert an array of single-digit integers into an integer in reverse (does⍝ not work if negative)arrToInt← {+/⍵×10*⍳≢⍵}
⍝ convert the integer into an array (does not work if negative) reverse it into⍝ an integer then check if in rangeSol← { inRangearrToInt⍎¨⍕⍵ }
EDIT:-
I do not know how, but I didn't think of operating on the absolute value and then multiplying the result by the sign.
Sol← { (×⍵) ×inRangearrToInt⍎¨⍕|⍵ }
The text was updated successfully, but these errors were encountered:
I would like to request to see the following problem solved:
My proposed solution(s):
I was not able to think of a straightforward solution that works on negative integers. Probably my solution for problem no. 2 (#11) affected my thinking in a negative way.
EDIT:-
I do not know how, but I didn't think of operating on the absolute value and then multiplying the result by the sign.
The text was updated successfully, but these errors were encountered: