Words with numbers

  • 12
The main method's first parameter is file1 and the second is file2. file1 contains lines with words separated by spaces. Write to file2 all the words that contain numbers, for example, a1 or abc3d. Separate the words with spaces. Close the streams.
You can't complete this task, because you're not signed in.
Comments (4)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Petros Level 23, Columbia, United States
28 August 2020, 17:02
Stack overflow saved me again:
This code will return true for a string that contains any number whatsoever. Sorry, didn't come up with another way on my own. This code works too well.
6 June 2020, 16:12
Depressing task. I love code gym but sometimes when you waste hours and hours because your code works as it asks but the verification fails it makes you want to quit. I cannot imagine what tasks at level 30 and above are like.
Tony Roy Level 41, Victorville, United States
2 April 2020, 15:45
A general suggestion: Comments suggest that quite a few students become frustrated thinking their code works but will not pass verification. Many times, it happens that the verification is good, and there is some test that we have not thought of (although sometimes I have never been able to identify the problem and get it to verify one way but not another). In this exercise, I thought I had a solution, but Guadalupe Gagnon kindly gave me a case to expose an error. Perhaps it would be worthwhile to supply such cases with verification. It is much easier to fix a problem when you know there is one, than when you think there is not. This might reduce frustration (and attrition). Let me say, though that I very much appreciate the instant feedback on exercises from the verification -- this is only a thought for improvement.
Radek Level 22, Warsaw, Poland
21 November 2018, 12:39
There is an error in assumption or validator. The validator expects pure numbers to be written to the output file, too. Solution done according to the conditions should write to the output file any string containing at least one letter and at least one digit. Such solution does not pass the validation. A string without any letters cannot have a lexical meaning, cannot be a word.