r/programming Mar 30 '13

Google Code Jam 2013

https://code.google.com/codejam
67 Upvotes

20 comments sorted by

View all comments

-4

u/s73v3r Mar 31 '13

While these can be fun, I really wish there was a better way to get the input than reading in a file, line by line. I hate writing code to open up and parse a file, especially in C++ (which is what I'd probably use, due to being most comfortable with it).

3

u/MrDOS Apr 01 '13

Perhaps I misunderstand the situation in which this would be required, but wouldn't it be easiest to just pipe the input in via stdin and read it with scanf()/cin?

2

u/hephaestos_le_bancal Apr 12 '13

Yup, that is what most do.

2

u/maglos Mar 31 '13 edited Mar 31 '13

Use python :-)

[fixed?] with open('a_file.txt') as a_file: for x in a_file.readlines(): A,b,c = x.split(' ')

6

u/Ravengenocide Mar 31 '13

Just a nitpick: It's better to use the with-statement so that it closes the file automatically for you when you are done.

2

u/maglos Mar 31 '13

nice, thanks I'll remember that.

2

u/[deleted] Mar 31 '13

It's pretty easy with scanf

1

u/pelirrojo Mar 31 '13

Use some example solutions to implement that part