googlecodejam 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ *.swp
2
+ *.swo
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Google Code Jam - Runner Utility for Ruby
2
+ Copyright (C) 2012 Endel Dreyer
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the "Software"),
6
+ to deal in the Software without restriction, including without limitation
7
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
+ and/or sell copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included
12
+ in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
20
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ Google Code Jam - Runner Utility for Ruby
2
+ ====
3
+
4
+ Get the output of tour Google Code Jam algorithms even more easily with this gem.
5
+
6
+ How to use
7
+ ---
8
+
9
+ Install the gem:
10
+
11
+ gem install googlecodejam
12
+
13
+ Write a class to resolve single entries the problem, like this:
14
+
15
+ # reverse_words.rb
16
+ class ReverseWords
17
+ def run(line)
18
+ line.split(' ').reverse.join(' ')
19
+ end
20
+ end
21
+
22
+ Run the utility by giving the source algorithm and input file (downloaded from Google Code Jam problem description)
23
+
24
+ googlecodejam -s reverse_words.rb -i B-small-practice.in
25
+
26
+ So you'll see the following output:
27
+
28
+ Running...
29
+ Output written in: "B-small-practice.out"
30
+ Finished in 0.000712ms.
31
+
32
+ Have fun!
33
+
34
+ License
35
+ ---
36
+
37
+ This gem is distributed under the MIT license. Please see the LICENSE file.
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/ruby
2
+ $: << './lib'
3
+ require 'googlecodejam'
4
+ require 'optparse'
5
+
6
+ options = {}
7
+ opts = OptionParser.new do |opts|
8
+ opts.banner = <<BANNER
9
+ ---------------------------------------------------------------------------------------------------
10
+ Google Code Jam - Runner Utility for Ruby
11
+ Usage:
12
+ googlecodejam -s src/algorighm_path.rb -i src/A-small-practice.in -o src/A-small-practice.out
13
+ googlecodejam -s src/algorighm_path.rb -i src/B-large-practice.in -o src/B-large-practice.out
14
+ ---------------------------------------------------------------------------------------------------
15
+ BANNER
16
+ opts.on("-s [path]", "--source [path]", "Path to your problem solving source code.") do |source|
17
+ options[:source] = source
18
+ end
19
+ opts.on("-i [path]", "--input [path]", "Path of the input file ('small.in' or 'large.in' path)") do |input|
20
+ options[:input] = input
21
+ end
22
+ opts.on("-o", "--output [path]", "Path where output ([type].out) file will be saved.") do |output|
23
+ options[:output] = output
24
+ end
25
+ opts.on_tail("-h", "--help", "Show this help message.") do
26
+ puts opts
27
+ exit
28
+ end
29
+ end
30
+ opts.parse!(ARGV)
31
+
32
+ if options.empty?
33
+ puts opts
34
+ else
35
+ if options[:source] && options[:input]
36
+ time = Time.now
37
+ puts "Running..."
38
+ GoogleCodeJam::Runner.new(options)
39
+ puts "Output written in: #{options[:output].inspect}"
40
+ puts "Finished in #{Time.now - time}ms."
41
+ else
42
+ puts "'source' and 'input' options are required. Use --help for details."
43
+ end
44
+ end
@@ -0,0 +1,101 @@
1
+ 100
2
+ this is a test
3
+ foobar
4
+ all your base
5
+ class per pony along only like less pony write alpha item all pony base base bar this snow five item alpha than entry than way this this like
6
+ snow a less item along only done this long base base way words foo too base too a class this class done would too bar base than like set five base only too the way set than entry with item this the set way entry class alpha pony foo cola base too foo like pony word five only chars chars foo set this done way item long snow way way chars word write all snow long this pony all pony foo this write cola base alpha bar words five than snow chars too bar the only
7
+ the with alpha with less foo words would way base a base a entry all word write set this this less words this base words base entry long too would along item alpha only too foo too word chars this chars entry class set cola foo class this too only way like only cola only item snow foo long
8
+ like cola than word base along alpha words chars would words would chars entry all words like way chars alpha item this snow way long too too pony words per a all less cola alpha five a this pony item word bar long only per done entry way all done the entry five the entry too foo bar class a this would word only along like pony base this pony done this bar way the along only class base too alpha along done
9
+ write long this chars done less cola way per cola the only a would this five like less only the write all class a word snow item like word chars pony alpha would item chars too alpha set per item with chars with only set long than word way set class bar way like snow set too like too set five five snow bar foo entry cola base this a word pony a item per would entry snow pony chars entry cola all this long item along the snow only bar set entry per cola than foo pony the too like only words along less word per words per set
10
+ way cola done less class a pony class the entry with with entry too item like too snow chars
11
+ than way cola chars way item cola words word chars chars per a write snow than alpha cola than done less word class too the only done per words with class chars like pony a foo pony than entry way this pony way base way than set snow would write way foo write snow too like alpha the set write entry only would write snow only way entry less base would this bar pony five chars entry pony way than word per item set with class done per five long only words a all five only entry bar per class like a entry bar only item class like the with less than cola with bar word foo entry all entry all long would along this only word too write foo item pony too long done chars
12
+ than per entry than bar than along alpha a class way foo class item a pony per words
13
+ done with foo five class words word long item the class entry done than too chars bar a only too base this class long long long entry foo five per item five item bar this entry item long per write less along write like snow this chars pony cola five word the base this done too would words this five than way foo all item per chars chars than a write like alpha long like per would base like with entry done than pony chars per all long cola item a would bar less along a words entry done done the foo this like five pony too with cola cola all the entry than set snow less only would class cola words this five alpha class a five entry entry word base long done this long would than all along the bar pony item per along all only base alpha only a than way
14
+ would a five set alpha bar chars words along would too way item a along cola less entry less word less five five done all along a way way snow five snow word pony chars too pony this entry than words set item snow along long along chars five snow five word way chars the along way write than entry snow than write a base class cola the way all would all all a way per words cola less only write class class set way long too like along would with a with item five pony foo set only foo only class per only words with class too set snow a words class too set with long done write per
15
+ too word way class less alpha long bar with class base all only entry per way class done the pony pony with this five pony way class foo item alpha only this like chars all write chars done base alpha all this set entry word too chars chars all along set the with item too word five five base long would a would item like along per
16
+ done cola this along too cola five along way words chars long word entry snow write words less foo per with foo alpha words way only set would only item would snow a only a with word less chars chars a the base item item less foo like words per a snow word write a like base the five would would foo the write base the per words write words alpha done done with
17
+ chars only this the cola entry would pony word with long a word alpha done words per entry snow pony would set five this item cola words per than write a way bar foo item set foo snow five along than bar way pony than pony with cola words write words all set item alpha too long than chars this write chars the all less bar the less than snow a bar set only way entry too words five
18
+ this too pony the a would this class foo class class set too class words per item like done item class done snow alpha only set set done class done words entry would five a write along five a per along would item per long base word done base like all class words set done than pony pony only this less all way done item would a all alpha too done would the long a with cola less this entry item words with foo five like write bar words pony long pony five way
19
+ alpha pony along would bar bar long the less cola less set only per a pony all word way than less pony set base write done a words pony bar with class only word this this set pony like the foo bar snow word chars write set class chars all less
20
+ cola done with class bar item too way set with only a word item too set set a only five too chars long snow entry less a words done foo only item foo word alpha would word class set all all foo pony only all a too entry only foo class done a done only long along only chars five pony bar base five per too a class cola with less pony write done than base base words along too only per
21
+ less only all write than cola cola done item with this would word too the only along per class pony class alpha only this entry snow the snow would item done five than set too
22
+ per all words per long alpha per way a would bar way item only bar this word only this than like too cola bar alpha less word than per way less pony than along like long
23
+ five only snow foo a word way chars chars pony foo bar
24
+ like set like cola the with word five foo done item with item set write per too way foo write class only set write along item pony alpha done snow like snow long chars entry less all per snow would cola way along the bar base set words word chars pony per class set than cola a long than only five
25
+ the entry like like long less a done along cola write long item snow long less long all alpha the along way long pony word alpha set class way a words done than less snow a bar the the like set like class way a alpha less with write this snow this way way class cola base cola like set with less alpha all would write five this would bar with a class this pony base chars like only all write snow would way class words per than five would done foo along too done word snow along would entry foo per with entry cola with item cola like class entry the like this foo all cola foo only way way would with entry write snow snow than per less alpha like words foo cola write than write snow long only a less too the like alpha per words item write set way set less
26
+ long five with the all way write entry all cola a
27
+ this this per chars like alpha only along would alpha base long bar than word entry class along the along this chars with set way too a way alpha snow than way than long bar a base this foo bar word with than class five write than would this the base a foo all
28
+ than less foo the less all only would snow five snow five all long five all words than bar than with chars alpha set a alpha this alpha too this chars alpha class class set class along way way foo the less done write a five along only write the the than chars alpha set cola this with like long would class than long base along chars five item entry write
29
+ base words bar only per alpha item word base less less five would would than this along snow base words write this less alpha foo with foo like along a write write base along this five class words long bar this bar all only less class along base alpha entry like bar too chars only too with less this snow less less item way with class entry item snow entry snow word per item all than foo pony write word item base
30
+ with entry too all words long bar class write along long class
31
+ alpha too bar snow too than cola base would set long alpha would write the bar done with done done snow all words way class set all per entry chars set word only done less foo along all too only only class than item way word less snow class than along all alpha only this too way only like word all long all word done this class foo foo class base bar along way bar less chars foo base all too item per done way class words alpha word foo with this per this set set entry the a than item
32
+ the would would word the class less write way item would long five only
33
+ write like done base long the way with too alpha with less per way less class cola with a item would foo all words entry alpha words class word five alpha base with all words entry snow would words class long per along per entry foo way along cola way like write snow a alpha cola per words base item only with less only long write like than five per alpha long too item way done word words all words base than entry done write words alpha only word than along cola write with foo cola pony all way would class like pony would five than alpha long cola pony all class along entry the chars only done word class all only entry done bar done cola all alpha would pony snow way with class per would with pony five bar
34
+ base would alpha foo bar base than long base chars class item word set pony the write base cola like this snow too set five this long bar write a chars done foo long five
35
+ item foo cola with long class words this write set
36
+ than cola chars cola done done bar alpha done set write base long all words entry alpha alpha word less like like like per snow entry chars word less like all five per words word along this word all set five write per per with entry cola per done bar word done class long this item long the too with way entry item like only cola word chars with a bar too with pony with would word too cola too like a the would pony write foo per write than item the this per like like than five set set
37
+ entry way write along all the five bar with along only snow like word cola a way done five a the chars per set than long entry five class snow than per words per only only the write than words item a words like along along word with set than foo snow would done this class snow along done bar bar foo words alpha set write less way cola snow foo set base along with write foo only way snow five cola write bar
38
+ way way alpha item foo foo
39
+ way with with snow along a a snow pony too base along set like pony alpha only entry with alpha class class alpha way item snow words way would this five write item this bar done pony word words a chars way a way only words less item like snow foo write with done this item write base all cola way pony base would the foo chars five cola pony too words
40
+ entry only alpha
41
+ the pony class too word would all the too set cola than this foo alpha with way would words this alpha pony done class class foo way this would base item way word write base than class snow cola cola foo snow base a too set word long five write done a a along alpha would pony would chars way less only cola cola words less words five write
42
+ word base word this item with item done chars base foo words the item per words words alpha per base class too alpha too the entry too entry like per alpha
43
+ the five a pony per foo entry long snow a all foo all only write would this the item item this the alpha like snow the all like only long too too words the base bar long class foo long per set a than this entry the foo snow than chars all way long set all long less class done along than cola item pony done set less bar this than set
44
+ foo write base word snow all per base this set entry than entry bar would foo less than only cola bar would base like five with bar item words class like pony base class item with base this would word done class than too like per long only write snow write item way pony base only five way long per the the with base this the five set way set too class this pony a snow per word alpha base foo with way chars pony this too way write word the way with with a cola foo class pony write five done bar chars like write less set way five word than too this a done per bar pony too set class write this pony all five bar words would way too would class less pony along than item than
45
+ long long this cola five write way than only item words less only all less five less per all way with bar per word entry along entry pony alpha words write would alpha long a with per than class this long write the five only snow bar five like five the less a long too only would this word entry write five five five set way alpha word chars bar long than bar write word foo five chars set done five set too like less long would words entry all pony too less all pony done write words word way done words snow too less alpha alpha word class along snow pony per
46
+ snow five foo class done alpha bar foo like alpha done class class would class would bar with per pony along a chars done bar write too class along entry alpha pony way bar the per five word set class this five pony this with five word less than a the snow done alpha item too item class less five like long foo write like only five cola set class pony like cola class alpha per per only would base entry along five item bar entry item class word chars chars would word foo less like with only too this cola done like too foo chars long
47
+ a too per per would per set set with than snow words long too too item all per too set the class a a a base too only snow this along way foo write along five chars words entry set five word the pony only chars chars five
48
+ than would base the with chars pony would along write class cola pony would per foo bar per class the all snow the write word per than set words along class snow entry cola the words item this entry per class all write way foo words long set cola
49
+ base all along a per base pony foo way class along five too all pony five than all per set set pony chars would chars per less than than item long alpha five per words base than pony item this per per a long word bar bar alpha done write chars chars a snow foo a the item alpha word long the would than entry set set pony way less write words than this this five snow with this words five the chars only pony five long than a write only entry base way class
50
+ word than class cola item this snow done way this foo long the word like per word base alpha long set like would words word bar cola base per
51
+ base than with too set bar with long like item bar like class long than alpha along five item write per per bar long words less done cola way cola this bar set all less too set entry base entry done snow all base pony chars entry like than too write only too pony the all than long done chars only less bar all base foo entry all chars would less with pony foo less a than all alpha bar word this base a done set set like the words like entry less with all foo alpha like would set less snow
52
+ item entry per foo five like word the bar too write words only entry pony only item set item write the per entry pony write done write pony five too entry would cola would set a like chars class foo only bar write cola this all a way this entry pony foo per than with word only base five snow write foo words like a would along pony like item snow set bar set five way pony base with bar a set foo than entry bar bar bar alpha bar write would set entry pony snow five foo
53
+ would write like long class foo base way like than like than word done alpha per item along less the pony done cola class too foo a the all the entry way chars than foo words word per done snow only bar five foo item words foo too word word per a item way less foo item less foo words less set pony too alpha too entry this this too way the item base bar set way five would long than snow word words the foo a less only long all cola chars this item than base set class snow long the alpha five
54
+ base would foo alpha write set along done only write the all five along words the all entry set foo cola class item snow chars write pony per entry words chars write than foo set words pony alpha long pony chars less cola word five words bar the this set all a snow class way bar five only base cola all than
55
+ class a all words done way all along class than words pony bar word less snow a bar the the too done too too item foo cola per words long class alpha foo per like set per base would long would pony five would write five foo set way the foo only the bar entry long all a item bar like like chars write pony way with too word class cola set foo write base done
56
+ alpha alpha than with less bar than chars bar long snow write item the chars way with per snow foo write less less all too than all per would would too snow the would per cola done foo pony snow entry long long this along all write would
57
+ class class set cola this pony cola long way like along pony set bar alpha pony foo only five
58
+ chars along way pony this would the way less chars long than along only chars all with too done snow foo all five pony than with foo long word the chars pony with way snow foo like less class chars write like bar snow this a alpha all set would base a class with write alpha with all item less cola with cola snow than along chars a this along write the snow a
59
+ chars this a with cola five done along five alpha words this chars class write would long chars cola only way set pony like entry per per than less per chars class chars foo along foo with less this cola the alpha the the way would write like per per way way snow write this this all pony pony item done entry bar this cola per than word alpha the with per chars than bar long write this than words word a set way this chars per five along foo this foo the like would a write this a class item pony a foo snow too all like than long pony only than words cola way too a pony the
60
+ per this item way base the too alpha word pony five alpha way class too along pony would words per entry done way a like long word with a base a all too only a class five cola way all item item with cola all class item five a per done long five all like the write way chars chars bar class item a per pony way bar than item bar chars along with foo like bar pony all set per five too would base long the this alpha than only cola along pony pony cola the too five item per like the entry way with
61
+ words too write set pony entry long write along foo done this words all a a long with too cola than pony only the only all five class than this the chars base class alpha this set this word set all class five less less a per words words all than alpha write chars snow too class words the a than class along too along base write entry write pony less cola alpha less the per all
62
+ words like cola like set a along base per class class entry a done set base bar five all set foo five this done along long cola word a words this write with too item alpha would with word set write along alpha foo per only cola this only only entry entry set the long entry foo word pony like base foo than item only write this pony snow class would write all this along along cola write less per words entry all too words item done five the long entry less item word per words words per chars a class snow all per set long entry this too a alpha only chars bar write this less item entry the chars item would pony entry only per long base long entry chars item with along too only only item chars word this item pony chars
63
+ alpha set cola all entry pony with less alpha pony item set would chars alpha class per pony all foo class too chars than a item done too way only this alpha along item bar than cola like all than a item class like word alpha pony a words this snow a set all foo than set class entry words bar class bar too class done than class entry per item only than class per item per foo would pony too too the words done chars words too set long would item five with five a like per along words this than only this entry cola
64
+ per only bar bar words a alpha cola too cola five
65
+ class the class entry chars cola per all words item entry bar entry than done entry than with five words would bar along write foo only per long way entry only alpha pony five foo foo set would a this than bar the too done too this done all set way with this the would foo entry done would way along like way bar chars long chars item with foo bar bar word the per class all than alpha write the per word alpha bar class the base five done along long along item like cola five only way bar a foo done per done pony class too class foo class word would foo foo class than the base
66
+ done entry this word would snow this cola along alpha write five too with set with long class the class the write entry foo like long this a write only entry write base foo set write a too done this way chars per pony entry way write done pony pony snow foo way way item a item class would long only cola a five entry along entry snow along like alpha done than way bar
67
+ class less the the word a the entry cola entry done would words word cola item with long pony done word cola less word cola chars the set entry all item this class all the snow with five class a done long word chars entry
68
+ would write the alpha than too along foo the write this this word less bar would base the alpha item than way cola like pony entry than snow base chars this a long class pony alpha way base pony chars way base too cola cola pony this foo cola way entry the long set too the all a would this all foo along less class pony entry cola only like base class word foo entry words snow five cola less along the chars less pony pony bar foo foo item the the way foo with this only done pony along set item entry would done set only only entry way class base five along words done per words words like this write like than the all
69
+ the class like bar the word than
70
+ pony the snow done word words word word cola this less way a chars the set alpha only chars class item word alpha alpha like five only done write would cola bar base word words cola with this snow pony too bar would words cola a pony snow would along bar done item per cola item set set alpha less way a write this write write done with entry way like set along item words like would along entry like long entry would foo way a along way word all too per long would too would words less item five this class would write chars bar long than snow cola write with than all cola a long like done chars per alpha class per a five cola base snow set
71
+ snow would snow long only class five item alpha chars less than cola like less a long chars too this word class too word five way set less base all set way per chars done with all than alpha with too the would only along done with set this alpha a class set cola a all item word along way alpha the alpha word pony done per class set long with like than snow only foo per along write class class pony cola foo chars pony a cola chars bar done base class entry like too with less write alpha done set done this done five entry along base cola base this bar words done word item the too less with
72
+ class set word item five pony pony this along would base with long less would per foo five set with alpha bar base long the bar too with chars bar all too entry bar pony like like cola per only words less with entry item done along long alpha alpha words foo words set bar set chars entry write per than way only entry item cola word alpha done set chars set snow than write base done along would long class alpha bar all done only write chars chars cola per item class chars entry snow like than too set pony would chars
73
+ long less all too base done snow chars per pony along along entry less the than chars five along bar the chars with write done words chars chars chars words per less the snow this than this per per this way than like entry along than entry item chars done all with with foo snow item per a only along words too a way all would a cola five alpha word only done way too the too chars with than than foo set alpha
74
+ alpha per chars write less less along way entry all pony less with way than like this item bar entry alpha all the cola this write alpha the the way too would class only snow less item alpha done with entry too the chars foo five the would way set class done set entry five all foo this five this bar item a per write less a a word too set base with per item snow five per long pony alpha cola way words foo set word word would pony chars with base base only set way base word would like this alpha cola pony than five entry bar pony bar too along set like snow per
75
+ words only words bar too write only five all
76
+ base along alpha alpha foo a the than way cola snow bar along like the snow write this words than class than set bar words along base with item along per word with words a foo done the item this less with this like long like set like snow cola words than all snow along foo cola way would a alpha way a long cola done done chars the class set pony alpha the all like along long cola only bar a item pony done would
77
+ only snow word base pony write way set cola with cola this chars set entry base pony all class base along chars write than entry cola than along base way word bar word all base with word alpha than bar words words a only base bar word word class with word would too like along foo item along only cola like than done along the less way snow too only like class with class this five item too item write the only way five with item foo than along set alpha too set way with foo than a word only set cola along base all along per pony
78
+ per cola a less way word write write chars pony five too along like set item done all than pony pony along along snow than all bar bar snow item word a pony word cola pony bar would along class word only the base entry the all along write cola way per five than base like entry alpha long done entry all done snow foo chars five along
79
+ like cola done foo than per item per words alpha all than too foo foo cola snow would snow cola long along than item would entry long entry done write word a class this base snow the chars five done along alpha along chars with a long only snow too like only item the too
80
+ less like along write than entry this done chars foo done alpha bar like base this with long along foo set like done entry write way word per less base would entry like write done a only write bar all foo too base write would class pony only less less entry less write entry per like per base too would foo long way entry way alpha along pony snow would too a entry foo than with the too with the the a base base only chars set bar write entry cola way base five words chars less snow write a way word would with snow only the the foo chars
81
+ per pony class this base along the item than too foo cola only pony all a words done done a with the snow less only alpha snow way bar only words five write less set base per with than base words done this this item item less way long five entry less like entry too five set done too way a like way word
82
+ foo only bar item pony less word five words too this the bar way less base per cola bar set less this all set foo way class word the this write item along cola alpha with all item a pony base entry snow too pony like words way alpha the snow long only done cola pony class like class pony only foo snow five
83
+ all entry five set pony the done set chars than than set word like this word base the done chars bar set with class word along alpha with with per pony with would class a less class cola this a entry with like only foo per like words chars class item long long all
84
+ item way done alpha a chars words this than like like cola words only less less done word this like set long way this foo less than item a five pony all all would set
85
+ along write entry class way class only foo write less foo too would item less long than foo with cola cola class per words all entry per would base bar with per set base write snow the along snow base too with chars than write too words only too than along cola words done word less alpha word than this than along less way would snow would all all item set done foo pony this entry way
86
+ class done bar foo pony set with foo the a too base with entry five than done write chars like per base class five done write
87
+ way bar words write base pony the this long per word entry like like words base with way like would along like bar write word cola entry a class along this chars done all a along like per this a only the write cola entry than words way snow chars base alpha pony the entry base too a too class all all pony long with bar the snow a like a write cola set long a less than five bar write along would too all base pony per base with this too write
88
+ cola set long foo bar item only words alpha done set like item write way write along way bar class chars entry way set pony word with entry base like less entry along class too words cola entry pony five done pony done bar base alpha done set five class like
89
+ per pony a snow than per alpha the words all five all alpha pony snow item along like less per done class along base words entry only foo too way with word too entry per way five base bar would way way all along all word less done set along long words per
90
+ pony write item words alpha class all would with class words base less all only too only five long set class the write chars entry all alpha long too bar cola would set way foo too too way too the the entry foo all set base alpha snow done item word all the only entry foo foo all less base bar way than like along word way only alpha foo this set along along with this long alpha words like set cola this would the class cola the write long set words five than like five done a foo all class all all chars only base long long base word item with per done too snow than entry write done like would
91
+ class this five bar snow bar than way along less the foo bar entry with snow less only write too the would chars cola foo word entry done word per long all along words way snow chars all all per cola done chars would like words the like chars along five entry with snow words along bar alpha alpha base long the less alpha entry alpha snow this like class long entry alpha snow less word
92
+ along bar cola class entry word entry set class pony would would like the done per would than item along word only along pony chars would less snow cola way base the pony word word pony bar way too the the like way chars write bar with only too write base words pony only along
93
+ base a pony along snow bar this chars all all word set than set like the way five five this class would foo item would too only five five base entry words way less write all with too write the the word pony foo all less less per this than base snow done foo long words entry long base word class pony per snow five a than five
94
+ done like than pony set too long cola than all done a set write word word entry item a would chars alpha foo long a along item class all item bar set cola alpha pony all along word this only item word entry way per than cola the with chars cola class alpha with per this a word snow word alpha five this too long words pony word entry all done less foo set foo alpha only only word word words class way write would per all only all done too five only would words done entry bar than than snow five a would word this would than class class too set long set with foo long five item done words this this foo this way
95
+ alpha cola than a foo item write chars alpha alpha done write base too done way all snow like base done this long write set entry item foo foo than the too only with a this too item than per class less per long words with long five item done this write words alpha long all class cola less pony all base class all only would entry like class like class per cola like with five class item pony cola snow base class foo done entry base this long per a set too cola like way write than alpha chars pony long like pony with word done all long than too pony foo along along less only a less base five a like alpha all all pony would set all write would done the done base like chars a all too pony only this with a than word than done long the word base
96
+ snow way words like the pony chars item long item set per words base like foo words only would base write snow entry item than base class cola snow with would would set class chars long less with too less item words item long less than would pony way way too words snow long item less only write only with per too way a long alpha per pony pony would word than way foo done foo set all five class only would only class cola along write alpha item word five long like write entry set only bar all word like less all cola base set pony long alpha per with alpha bar too less per item pony entry the less entry cola snow chars snow like item pony foo write like all less a only set per the item write chars base set words long write words base write five would per way only base per
97
+ set all long foo
98
+ would entry like alpha like word entry pony write bar than item per item foo snow cola the along chars the snow along pony set too like this a along per only along write bar alpha the would this this would snow item way long words like cola five less only like with a chars cola alpha foo a class base done done long item item entry words alpha this base bar would write write base with write with along only words words too a pony way than class would base all set a done like alpha set words bar set class base a long word entry word like way word item pony words per only along foo item only words less
99
+ snow would with less per all this done long this foo a less per long the like snow the bar pony set write alpha words done way alpha way words the item a this words
100
+ too alpha the only would class bar foo would write snow all five bar item too a done entry a only like class long set foo than this along the write less foo word snow way
101
+ entry too a the item less snow base less bar chars only a only the would than pony this a only than than this words long than than cola five word per with snow set less all too the too the would only item less alpha base
@@ -0,0 +1,6 @@
1
+ 5
2
+ this is a test
3
+ foobar
4
+ all your base
5
+ class
6
+ pony along
@@ -0,0 +1,5 @@
1
+ class ReverseWords
2
+ def run(line)
3
+ line.split(' ').reverse.join(' ')
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ spec = Gem::Specification.new do |s|
2
+ s.name = 'googlecodejam'
3
+ s.version = '0.1'
4
+ s.summary = 'Google Code Jam - Runner Utility for Ruby'
5
+ s.description = 'Google Code Jam - Runner Utility for Ruby'
6
+ s.author = ['Endel Dreyer']
7
+ s.email = ['endel.dreyer@gmail.com']
8
+ s.homepage = "https://github.com/endel/googlecodejam"
9
+
10
+ s.files = `git ls-files`.split("\n").select {|f| !f.index('.rb.swp') }
11
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ s.require_path = "lib"
13
+ s.bindir = "bin"
14
+ end
@@ -0,0 +1 @@
1
+ require 'googlecodejam/runner'
@@ -0,0 +1,45 @@
1
+ module GoogleCodeJam
2
+ class Runner
3
+
4
+ def initialize(options={})
5
+ instance = self.initialize_from_path(options[:source])
6
+
7
+ input = open(options[:input]).read
8
+ options[:output] ||= options[:input].gsub('.in', ".out")
9
+
10
+ num, *lines = input.split("\n")
11
+ output = lines.each_with_index.inject("") do |r, (n, i)|
12
+ begin
13
+ r + (i+1==1 ? "" : "\n") + "Case ##{i+1}: #{instance.run(n)}"
14
+ rescue => e
15
+ puts e.backtrace
16
+ raise "Line: #{n.inspect}"
17
+ end
18
+ end.strip
19
+
20
+ File.open(options[:output], 'w+') {|f| f.write(output) }
21
+ options
22
+ end
23
+
24
+ protected
25
+ def initialize_from_path(path)
26
+ full_path = File.expand_path(path)
27
+ raise "'#{full_path}' not found." unless require full_path
28
+ filename = File.basename(path, File.extname(path))
29
+ klass_name = filename.split('_').map {|w| w.capitalize}.join
30
+
31
+ if Object.const_get(klass_name)
32
+ klass = Object.const_get(klass_name)
33
+ end rescue nil
34
+
35
+ if klass
36
+ instance = klass.new
37
+ raise "#{instance.name} must implement #run method." unless instance.respond_to?(:run)
38
+ instance
39
+ else
40
+ puts "Error: '#{path}' is expected to define '#{klass_name}'"
41
+ abort
42
+ end
43
+ end
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: googlecodejam
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: "0.1"
6
+ platform: ruby
7
+ authors:
8
+ - Endel Dreyer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-04-07 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: Google Code Jam - Runner Utility for Ruby
17
+ email:
18
+ - endel.dreyer@gmail.com
19
+ executables:
20
+ - googlecodejam
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - .gitignore
27
+ - LICENSE
28
+ - README.md
29
+ - bin/googlecodejam
30
+ - example/reverse_words/B-large-practice.in
31
+ - example/reverse_words/B-small-practice.in
32
+ - example/reverse_words/reverse_words.rb
33
+ - googlecodejam-0.1.gem
34
+ - googlecodejam.gemspec
35
+ - lib/googlecodejam.rb
36
+ - lib/googlecodejam/runner.rb
37
+ homepage: https://github.com/endel/googlecodejam
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options: []
42
+
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.8.17
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Google Code Jam - Runner Utility for Ruby
64
+ test_files: []
65
+
66
+ has_rdoc: