Your boss has recently learned of this interesting programming language called English. He has had this "revolutionary" idea, he wants to code with you to double code production rates! Since he is not a tech savvy, he wants you to write a compiler for it so that he can code too!
Now, you are an evil lazy programmer and obviously will not write a program to compile this ridiculously complex language. Instead, you are going to make sure there is always an error in your boss's code, so that he never gets to the actual compilation and is stuck fixing grammar errors instead of coding.
The challenge is to write a program that can be run from the terminal, and accepts a file path as an argument. The program has to:
- modify the file input by introducing a typo.
- Pretend to fail compilation due to encountering the typo you introduced.
- Running the program on copies of the same file should not introduce the same typo twice in a row.
To illustrate the challenge, running your program on this file:
Take an array as input. Sort the array. Output the array.
should output something along the lines of
Error on line 1: 'Take an arqay as input.' ^ arqay is not a valid identifier.
and the file that you told the program to compile should now look like:
Take an arqay as input. Sort the array. Output the array.
Here are some more details on the specs of the program:
Your program is allowed to assume that swapping any character in the program your boss inputs for a different random character will cause a grammar error.
Your program should not use non alphabetical characters to create errors in your bosses code. Your boss would never use a number or symbol, and he would find out that something is afoot.
Your program should only introduce errors to the words in your boss's program. Do not change the spaces in the sentences, or the punctuation.
Your program should not alter the case of the program your boss tries to compile, meaning errors like
arQay are invalid. This prevents errors like
take instead of
Take happening, or
Array instead of
Your program should output the error by first stating what line the error is at:
Error on line <insert line number here>:
It should then print out the line with the error inside
' symbols. On the next line it should place a
^ symbol under the word with the error, and finally it should have some text describing the error (this part is up to you, you can say whatever you want there as long as it describes an error).
You can assume that the input file exists and it is not empty. You can also assume the input file has no grammatical errors before you add one.
-60 bytes if the errors your code introduces are not completely random, but typo-based as in this question.
-60 bytes for at least 5 different error messages, randomly alternating.
-60 bytes if your program has a 1 in 100 chance or less to output some demotivational message to your boss.
EDIT: The byte count of the messages do not count towards your score. (Thanks to Martin Büttner for this good idea)
This is code-golf, shortest byte count wins. Please do not golf the error message content, your boss wont be happy if he can't understand the error messages, and will ask you to fix them for him.