Just a small comment:

I'm actually one of those who doesn't use file reads in the code. Instead I
use command like:

time cat "$INPUT_FILE" | ./"$EXEC_FILE" "debug"

or

> time cat "$INPUT_FILE" | ./"$EXEC_FILE" > "$OUTPUT_FILE"


switching between 2 depending on whether I'm debugging or not.

It gives me flexibility of running the code independently from the input
file name. Even more, I usually work on one problem at a time and the input
file to process is the last modified "*.in" file in the folder, so I added
some magic to determine which input file to process:

INPUT_FILE=`ls -t -1 | grep "in$" | head -1`


This way, I never actually enter input file manually at all – I either
download new input or edit the sample input file.

P.S. This may not be the most efficient bash usage, as you don't need cat
in first example (you can redirect stdin instead) or grep in second (you
can specify mask in ls command), but it was written fast to save some time
for coding, instead of beautifying the bash code :)




On 16 March 2016 at 19:20, 'Pablo Heiber' via Google Code Jam <
[email protected]> wrote:

> Hi,
>
> In a nutshell, I guess most people are not copy/pasting the input but
> redirecting stdin to read from a file.
>
> You can redirect files to the standard input by using " < filename" after
> your execution line. Similarly, you can use " > filename" to have the
> output written to a file instead of to the console. This is a good way to
> avoid naming the files in your code, and switch easily between outputting
> to the console or to a file depending on whether you are running on samples
> to test/debug or on an input file to submit.
>
> We will have a tutorial with a more complete description on this in
> codejam's site soon. Stay tuned!
>
> Best,
> Pablo
>
> On Wed, Mar 16, 2016 at 5:15 AM, kunal kotiyal <[email protected]>
> wrote:
>
>> I have seen some source files of Google code jam , many peoples are not
>> reading from files i.e they are coping and pasting I/p to the console and
>> doing same with o/p file. Is it faster than working with files.
>> I mean they are using simply cin>>a instead of f>>a.
>> Which method is faster?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Code Jam" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/google-code/7d5e528e-6958-4ff9-9800-d3f7ce2a0295%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/CANa5jcAH7yO5AP%2BAZdxKyJTTHnutw7_iHH2Fa%2B874FNdESEy%3DQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/google-code/CANa5jcAH7yO5AP%2BAZdxKyJTTHnutw7_iHH2Fa%2B874FNdESEy%3DQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Best regards,
Anton Popov

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CADp5X8Mgp-p8ACXBxzCM3F%2BZ-3w6uQFe6wUnNXBipjCd2ZF1Yw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to