What happens
I am doing a code challenge of Codeabbey - Challenge 140 and I already made the necessary code, when I execute a value between 1 to 80 everything is fine, but when I run higher numbers, it marks an error that I can’t understand.
Error Message
Exception: pipe2: too many open files
What do you understand or find about that problem
I understand that the program does an operation in which it executes many operations and does not allow me to obtain the proper result (large result).
When they are values between 1 and 80 or to be precise between 10 and 20, everything works fine.
You make any workaround? What did you do?
I tried converting the numbers to strings, changing the way I input the data, but nothing works.
Evidences
Code
use str
use math
fn input_data []{
put [(each [line]{
put [(str:split ' ' $line)]
})]
}
fn fact [x]{
if (<= $x 1) {
echo 1
} else {
echo (* $x (fact (- $x 1)))
}
}
fn catNum [n]{
put (/ (fact (* $n 2)) (* (fact $n) (fact (+ $n 1))))
}
fn calculate [data]{
each [values]{
catNum $values[0]
} $data
}
echo (calculate (input_data))
This is how I’m currently passing the data (as args)
When DATA.lst contains a value 10
cat DATA.lst | elvish code.elv
Result: 2674440
When DATA.lst contains a value 254
Error code
cat DATA.lst | elvish code.elv
Exception: pipe2: too many open files
I need help with
I would need help to understand if there is another method in which I can get a large number without generating an error.
Thanks.