Why do this all manually? There are far easier ways. #144
Replies: 4 comments 6 replies
-
Update: Converting to numerals from words has been done before. |
Beta Was this translation helpful? Give feedback.
-
Mod math is for return !(int & 1) (EDIT: Use better inclusive languages.) |
Beta Was this translation helpful? Give feedback.
-
Are you sure? Do you have any source for that? |
Beta Was this translation helpful? Give feedback.
-
Also, we're almost done, roadmap: https://github.com/samuelmarina/is-even/pull/136/files?short_path=b335630#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5. Do you really want to throw away all this work? |
Beta Was this translation helpful? Give feedback.
-
When working with Arabic numerals:
Dividing by 2 and getting the remainder (
% 2
) should return0
, as even numbers have no remainder when divided by 2.When working with written-out numbers:
There could be an internal system to turn strings like
"seven"
to7
."seventy-seven"
could be separated [into"seventy"
and"seven"
] and converted to70
+7
(thus,77
). Although it'd be a bit difficult, words like "billion," "million," and "thousand" are not needed in the conversion.For example,
373,051
is said as "three hundred seventy-three thousand and fifty-one." Only looking at373
(and removing the "thousand") could be 373 or 373,000, thanks to the word "thousand" denoting it's place value. If373
is followed by more numbers, for example, then it can be inferred that373
is not in the hundreds place, but the thousands/millions/billions/etc place.I don't feel like I explained this right; but I know it is possible to convert from words to numerals.
Once they have been converted to integers, the same
% 2
code [as above] can be run again, and the number's evenness can be returned.I find it ridiculously ineffective manually writing the evenness of all numbers out, plus numbers are infinite; making this task effectively impossible. (Unless JavaScript has an integer limit, i.e 2^63. I don't know, I use Java)
Beta Was this translation helpful? Give feedback.
All reactions