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/rand" | |
"strings" | |
"time" | |
) | |
type Player struct { |
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
TEENS = { | |
0 => 'Ten', | |
1 => 'Eleven', | |
2 => 'Twelve', | |
3 => 'Thirteen', | |
4 => 'Fourteen', | |
5 => 'Fifteen', | |
6 => 'Sixteen', | |
7 => 'Seventeen', | |
8 => 'Eighteen', |
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
def solution(a,b) | |
whole_squares = 0 | |
(a..b).to_a.each do |i| | |
whole_squares += 1 if Math.sqrt(i) % 1 == 0 | |
end | |
whole_squares | |
end | |
puts solution(4, 17) |
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 ( | |
"bytes" | |
"database/sql" | |
"encoding/csv" | |
"encoding/json" | |
"fmt" | |
_ "github.com/go-sql-driver/mysql" | |
"io/ioutil" |
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
def tree_builder(node) | |
if node.children.empty? | |
node | |
else | |
{ node.name => node.children.map{ |node| tree_builder(node) } } | |
end | |
end |
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
def isPalindrome(word) | |
word == word.reverse | |
end | |
def isPalindrome2(word) | |
i = 0 | |
lastIndex = word.length - 1 | |
while i != lastIndex - i | |
if word[i] == word[lastIndex - i] | |
i += 1 |
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
def recursiveFibonacci(n) | |
if n == 0 || n == 1 | |
n | |
else | |
recursiveFibonacci(n-1) + recursiveFibonacci(n-2) | |
end | |
end | |
def iterativeFibonacci(n) |
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 ( | |
"bufio" | |
"database/sql" | |
"fmt" | |
_ "github.com/go-sql-driver/mysql" | |
"os" | |
"reflect" | |
"strconv" |
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 edu.hu.bigdata; | |
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.util.*; | |
import org.bson.Document; | |
import org.bson.json.JsonParseException; | |
import com.mongodb.MongoClient; |
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
1) select title, rating from movies where rating is not null order by rating asc limit 50; | |
2) select title from movies where rating is null order by title asc; | |
3) select title from movies where synopsis ilike '%thrilling%'; | |
4) select title, year, rating from movies join genres on movies.genre_id = genres.id where genres.name = 'Science Fiction & Fantasy' AND movies.year BETWEEN 1980 AND 1990 order by rating desc; | |
5) select actors.name, movies.title, movies.year from cast_members join actors on actors.id = cast_members.actor_id join movies on movies.id = cast_members.movie_id where character ilike '%james bond%' order by year desc; |
NewerOlder