Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 4e31627b74ab580001000007

PHP <--> Java class conversion Part 1

Convert this tiny php class to adequate java one.

Start file
<?php
class Foo
{
	private $var1;
	private $var2;

	public function Foo($val)
	{
		$this->init($val);
		$this->doSomething();
	}

	private function init($val)
	{
		$this->var1 = $val;
	}
	
	private function doSomething()
	{
		$this->var2 = sqrt($this->var1);
	}

	public function getResult()
	{
		return $this->var2;
	}
}
?>
End file
public class Foo
{
	private double var1;
	private double var2;

	public Foo(double val)
	{
		init(val);
		doSomething();
	}

	private void init(double val)
	{
		var1 = val;
	}
	
	private void doSomething()
	{
		var2 = Math.sqrt(var1);
	}

	public double getResult()
	{
		return var2;
	}
}

View Diff

1,2c1
< <?php
< class Foo
---
> public class Foo
4,5c3,4
< 	private $var1;
< 	private $var2;
---
> 	private double var1;
> 	private double var2;
7c6
< 	public function Foo($val)
---
> 	public Foo(double val)
9,10c8,9
< 		$this->init($val);
< 		$this->doSomething();
---
> 		init(val);
> 		doSomething();
13c12
< 	private function init($val)
---
> 	private void init(double val)
15c14
< 		$this->var1 = $val;
---
> 		var1 = val;
18c17
< 	private function doSomething()
---
> 	private void doSomething()
20c19
< 		$this->var2 = sqrt($this->var1);
---
> 		var2 = Math.sqrt(var1);
23c22
< 	public function getResult()
---
> 	public double getResult()
25c24
< 		return $this->var2;
---
> 		return var2;
28d26
< ?>

Solutions by @nickandbro:

Unlock 41 remaining solutions by signing in and submitting your own entry
Created by: @robrob12

63 active golfers, 254 entries

Solutions by @nickandbro:
65
#5 - nickGPT / @nickandbro

08/28/2024 at 10:43PM

67
#>6 - nickGPT / @nickandbro

08/28/2024 at 10:43PM

68
#>8 - nickGPT / @nickandbro

08/28/2024 at 10:43PM

69
#>9 - nickGPT / @nickandbro

08/28/2024 at 10:43PM

71
#>11 - nickGPT / @nickandbro

08/28/2024 at 10:43PM

72
#>12 - nickGPT / @nickandbro

08/28/2024 at 10:43PM

77
#>13 - nickGPT / @nickandbro

08/28/2024 at 10:43PM

78
#>14 - nickGPT / @nickandbro

08/28/2024 at 10:42PM

81
#>18 - nickGPT / @nickandbro

08/28/2024 at 10:42PM

82
#>20 - nickGPT / @nickandbro

08/28/2024 at 10:42PM

83
#>21 - nickGPT / @nickandbro

08/28/2024 at 10:42PM

84
#>22 - nickGPT / @nickandbro

08/28/2024 at 10:42PM

85
#>23 - nickGPT / @nickandbro

08/28/2024 at 10:42PM

87
#>24 - nickGPT / @nickandbro

08/28/2024 at 10:42PM

88
#>25 - nickGPT / @nickandbro

08/28/2024 at 10:42PM

89
#>26 - nickGPT / @nickandbro

08/28/2024 at 10:42PM

90
#>28 - nickGPT / @nickandbro

08/28/2024 at 10:42PM

91
#>31 - nickGPT / @nickandbro

08/28/2024 at 10:41PM

93
#>33 - nickGPT / @nickandbro

08/28/2024 at 10:41PM

95
#>34 - nickGPT / @nickandbro

08/28/2024 at 10:41PM

96
#>35 - nickGPT / @nickandbro

08/28/2024 at 10:41PM

98
#>37 - nickGPT / @nickandbro

08/28/2024 at 10:41PM

100
#>38 - nickGPT / @nickandbro

08/28/2024 at 10:41PM

101
#>39 - nickGPT / @nickandbro

08/28/2024 at 10:41PM

109
#>41 - nickGPT / @nickandbro

08/28/2024 at 10:41PM

113
#>43 - nickGPT / @nickandbro

08/28/2024 at 10:41PM

114
#>44 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

115
#>45 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

124
#>47 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

127
#>48 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

129
#>50 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

136
#>50 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

138
#>54 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

140
#>55 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

145
#>56 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

146
#>57 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

147
#>58 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

151
#>58 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

174
#>61 - nickGPT / @nickandbro

08/28/2024 at 10:40PM

187
#>62 - nickGPT / @nickandbro

08/28/2024 at 10:39PM

465
#>63 - nickGPT / @nickandbro

08/28/2024 at 10:39PM