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
function getMonday(d) { | |
d = new Date(d); | |
var day = d.getDay(), | |
diff = d.getDate() - day + (day == 0 ? -6:1); // adjust when day is sunday | |
return new Date(d.setDate(diff)); | |
} | |
getMonday(new Date()); | |
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 happy_number(number) | |
sum_of_digits = [] | |
flag = true | |
while(number != 1) | |
number = digits_square_sum(number) | |
if sum_of_digits.include?(number) | |
flag = false | |
break | |
else | |
sum_of_digits << number |
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 curious_numbers | |
curious_number_list = [] | |
(1..9999999999).each_slice(100000).each do |numbers| | |
numbers.each do |number| | |
square = number ** 2 | |
number_of_digit = number.to_s.length | |
if(square.to_s[-number_of_digit..-1].to_i == number) | |
curious_number_list << number | |
end | |
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"strings" | |
) | |
func main() { |
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 "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
package main | |
// similar to require in ruby | |
import "fmt" | |
func main(){ | |
fmt.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
puts "Commenting Code in Ruby" | |
# this is single line comment in ruby | |
=begin | |
This is multiline | |
Comment in ruby | |
=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
package main | |
import "fmt" | |
func main(){ | |
fmt.Println("Commenting in Go") | |
// this is single line comment in Go | |
/* this is multiline | |
Comment in Go */ | |
} |
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
#Ruby | |
{name: 'Nikita', lastname: 'Acharya'}.each do |k, v| | |
puts k, v | |
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
// Go | |
kvs := map[string]string{"name": "Nikita", "lastname": "Acharya"} | |
for k, v := range kvs { | |
fmt.Printf("%s -> %s\n", k, v) | |
} |
OlderNewer