This file contains 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
def fisher_yates_shuffle(array) | |
n = array.length | |
while n > 0 | |
i = rand(n-=1) | |
array[i], array[n] = array[n], array[i] | |
end | |
return array | |
end |
This file contains 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
public static void fisher_yates_shuffle(int[] array){ | |
Random random = new Random(); | |
for (int n = 0; n < array.length; n++){ | |
int i = n + random.nextInt(array.length - n); | |
int tmp = array[i]; | |
array[i] = array[n]; | |
array[i] = tmp; | |
} | |
} |
This file contains 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
p "Hello World!" |
This file contains 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
class Main{ | |
public static void main(String[] args){ | |
System.out.println("Hello World!"); | |
} | |
} |
This file contains 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
fun main(args : Array<String>) { | |
println("Hello World!") | |
} |
This file contains 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
using System; | |
using MySql.Data.MySqlClient; | |
static void Main() | |
{ | |
var conn = "Server=localhost;Database=SEU_BANCO_AQUI;Uid=SEU_USUARIO_AQUI;Pwd=SUA_SENHA_AQUI"; // Dados do banco | |
var connection = new MySqlConnection(conn); // Cria a conexão | |
var command = connection.CreateCommand(); // Cria um comando a ser executado | |
try | |
{ | |
connection.Open(); // Abre a conexão |
This file contains 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
puts "Olá Mundo" | |
p "Olá Mundo" | |
print "Olá Mundo" |
This file contains 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
"12345".to_i #=> 12345 | |
"99 red balloons".to_i #=> 99 | |
"0a".to_i #=> 0 | |
"0a".to_i(16) #=> 10 | |
"hello".to_i #=> 0 | |
"1100101".to_i(2) #=> 101 | |
"1100101".to_i(8) #=> 294977 | |
"1100101".to_i(10) #=> 1100101 | |
"1100101".to_i(16) #=> 17826049 |
This file contains 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
arr = [1, 2, 3, 4, 5, 6] | |
arr[2] #=> 3 | |
arr[100] #=> nil | |
arr[-3] #=> 4 | |
arr[2, 3] #=> [3, 4, 5] | |
arr[1..4] #=> [2, 3, 4, 5] | |
arr.first #=> 1 | |
arr.last #=> 6 |
This file contains 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
grades = { "Jane Doe" => 10, "Jim Doe" => 6 } | |
options = { :font_size => 10, :font_family => "Arial" } | |
options = { font_size: 10, font_family: "Arial" } | |
options[:font_size] # => 10 | |
grades = Hash.new | |
grades["Dorothy Doe"] = 9 |
OlderNewer