| 
View
 

PE011

Page history last edited by Kenneth Finnegan 16 years, 5 months ago

Project Euler Problem #11

 

The hardest part of this problem, by far, was formatting the huge list of numbers so it would be useable in the program.  I originally tried scanning it in as a string, but it was giving me problems (I hate strings), so I decided to convert them straight into an array using some vim-foo.

 

1) copy paste 20 lines of numbers into vim.

2) add { } to the beginning and end.

3) In command mode "19J", which moves the next 19 lines onto this on, to make one line of numbers.

4) ":s/ /,/g" substitute commas for all the spaces

5) ":s/,0/,/g" removes any of the numbers that happen to be lead by a 0, since they look like they're in octal.

 

From there, I resorted the one long array into a [20][20] array, which I did all the work on, which was pretty trivial.

 

PE011.c 

 

 


Return to list of solutions

Comments (0)

You don't have permission to comment on this page.