Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Ruby: 31 21 characters

(This is a rewrite of AbhijitAbhijit's Python solutionPython solution. If you like the base idea, upvote his answer, like I did.)

open($0,?a)<<"+1";p 1

Sample run:

bash-4.2$ ruby increment.rb 
1

bash-4.2$ ruby increment.rb 
2

bash-4.2$ ruby increment.rb 
3

Ruby: 31 21 characters

(This is a rewrite of Abhijit's Python solution. If you like the base idea, upvote his answer, like I did.)

open($0,?a)<<"+1";p 1

Sample run:

bash-4.2$ ruby increment.rb 
1

bash-4.2$ ruby increment.rb 
2

bash-4.2$ ruby increment.rb 
3

Ruby: 31 21 characters

(This is a rewrite of Abhijit's Python solution. If you like the base idea, upvote his answer, like I did.)

open($0,?a)<<"+1";p 1

Sample run:

bash-4.2$ ruby increment.rb 
1

bash-4.2$ ruby increment.rb 
2

bash-4.2$ ruby increment.rb 
3
thanks to @steenslag
Source Link
manatwork
  • 20.6k
  • 5
  • 51
  • 81

Ruby: 3131 21 characters

(This is a rewrite of Abhijit's Python solution. If you like the base idea, upvote his answer, like I did.)

open($0,?a){|f|f.write'+1'};p<<"+1";p 1

Sample run:

bash-4.2$ ruby increment.rb 
1

bash-4.2$ ruby increment.rb 
2

bash-4.2$ ruby increment.rb 
3

Ruby: 31 characters

(This is a rewrite of Abhijit's Python solution. If you like the base idea, upvote his answer, like I did.)

open($0,?a){|f|f.write'+1'};p 1

Sample run:

bash-4.2$ ruby increment.rb 
1

bash-4.2$ ruby increment.rb 
2

bash-4.2$ ruby increment.rb 
3

Ruby: 31 21 characters

(This is a rewrite of Abhijit's Python solution. If you like the base idea, upvote his answer, like I did.)

open($0,?a)<<"+1";p 1

Sample run:

bash-4.2$ ruby increment.rb 
1

bash-4.2$ ruby increment.rb 
2

bash-4.2$ ruby increment.rb 
3
Source Link
manatwork
  • 20.6k
  • 5
  • 51
  • 81

Ruby: 31 characters

(This is a rewrite of Abhijit's Python solution. If you like the base idea, upvote his answer, like I did.)

open($0,?a){|f|f.write'+1'};p 1

Sample run:

bash-4.2$ ruby increment.rb 
1

bash-4.2$ ruby increment.rb 
2

bash-4.2$ ruby increment.rb 
3