Solve Me First

  • + 0 comments

    Bash Solution:

    solveMeFirst() {
      local a=$1
      local b=$2
    
      
      if (( a < 1 || b > 1000 )); then
        echo "Error: inputs must be in range 1..1000" >&2
        exit 1
      fi
    
      # print the sum
      echo $(( a + b ))
    }
    
    # read two numbers (space- or newline-separated)
    read -r a
    read -r b
    
    solveMeFirst "$a" "$b"