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() { | |
// Assuming you have access to distinct elements. If not this needs to be done | |
distinct := map[string]int{"a": 0, "b": 0, "c": 0, "d": 0} | |
// Homework: Read input from desired | |
given := []string{"a", "a", "a", "b", "b", "c", "c", "c", "d", "d"} | |
// expected := []string{"a", "b", "c", "d", "a", "b", "c", "d", "a", "c"} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<content> | |
<item> | |
<source>SingSaver</source> | |
<headline>**EXCLUSIVE FOR HWZ Members** Apply for a card & get ADDITIONAL $40 NTUC or Uber voucher upon card approval!</headline> | |
<thumbnail>https://s3-ap-northeast-1.amazonaws.com/cgblogassets/wp-content/uploads/sites/2/2016/11/18095443/Airmiles1.png</thumbnail> | |
<link>https://www.singsaver.com.sg/blog/singsaverxhwz?utm_source=hardwarezone&utm_content=airmilesexclusive</link> | |
</item> | |
<item> | |
<source>SingSaver</source> |
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 greatest_prime_factor(n) | |
divider = 2 | |
finder = n | |
factors = [] | |
while divider < finder | |
if n%divider == 0 | |
factors << divider | |
finder = finder/divider | |
factors << finder | |
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
# ignore all the log files while commiting | |
log/*.log | |
#ignore the local db config | |
config/database.yml | |
#ignore db files | |
db/*.sqlite3 | |
#if you are using emacs - this is for ignoring emacs backups and file locks | |
.#* | |
#this is for other editors | |
*~ |
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 binary_search(sorted_array, number_to_be_searched) | |
size = sorted_array.size | |
if number_to_be_searched < sorted_array[0] || number_to_be_searched > sorted_array[size-1] | |
puts "Number not found" | |
return | |
end | |
middle_index = size/2 | |
middle_element = sorted_array[middle_index] | |
if middle_element === number_to_be_searched | |
middle_index = middle_index/2 |