This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add this function on your .bashrc file to echoed Go version | |
function go_version { | |
version=$(go version) | |
regex="(go[0-9].[0-9].[0-9])" | |
if [[ $version =~ $regex ]]; then | |
echo ${BASH_REMATCH[1]} | |
fi | |
} | |
# and add to your PS1, for example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net" | |
"os" | |
"fmt" | |
) | |
func main() { | |
// if script running without argument, give usage information |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PASS | |
f("I am learning Go!") = | |
map[string]int{"I":1, "am":1, "learning":1, "Go!":1} | |
PASS | |
f("The quick brown fox jumped over the lazy dog.") = | |
map[string]int{"brown":1, "over":1, "lazy":1, "dog.":1, "The":1, "quick":1, "fox":1, "jumped":1, "the":1} | |
PASS | |
f("I ate a donut. Then I ate another donut.") = | |
map[string]int{"I":2, "ate":2, "a":1, "donut.":2, "Then":1, "another":1} | |
PASS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
var n, smallest, biggest int | |
x := []int{ | |
48,96,86,68, | |
57,82,63,70, | |
37,34,83,27, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func Sqrt(x float64) float64 { | |
z := x | |
n := 0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tujuan | |
// Mencari volume bangun Kerucut dan setengah bola | |
// | |
// Fakta | |
// volume total = volume kerucut + 1/2 volume bola | |
// volume kerucut = 1/3 pi r^2 t | |
// volume bola = 4/3 pi r^2 | |
// | |
// Algoritma | |
// 1. input data r(jari-jari) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// definisi bilangan prima : | |
// bilangan prima adalah biangan yang hanya memiliki 2 faktor, 1 dan dirinya sendiri. | |
// contoh: 2,3,5,7 | |
// logika program: | |
// jika angka tersebut bilangan prima, maka angka tersebut tidak habis dibagi bilangan | |
// sebelumnya kecuali 1, dengan kata lain angka tersebut hanya memiliki 2 faktor: 1 dan dirinya sendiri. | |
// misal angka 7, maka 7 tidak akan bisa habis dibagi oleh 2,3,4,5,6 | |
// | |
// jika angka tersebut bukan bilangan prima maka angka tersebut habis dibagi bilangan sebelumnya |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set background=dark | |
highlight clear | |
if exists("syntax on") | |
syntax reset | |
endif | |
let g:colors_name="basedonpallete" | |
" RGB XTERM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[6] pry(main)> load 'pyramid.rb' | |
=> true | |
[7] pry(main)> pyr1 = Pyramid.new(5) | |
=> #<Pyramid:0x007fb08e74a9a0 | |
@pyramid=[[1], [2, 1], [3, 2, 1], [4, 3, 2, 1], [5, 4, 3, 2, 1]], | |
@size=5> | |
[8] pry(main)> print pyr1 | |
1 | |
2 1 | |
3 2 1 |