Skip to content

Instantly share code, notes, and snippets.

View barunthapa's full-sized avatar
💭
going with go

Barun Thapa barunthapa

💭
going with go
View GitHub Profile
@barunthapa
barunthapa / Readme.md
Last active August 18, 2020 06:18
Sort numbers 5 at a time from list of 25 to find out top 3

It is a sorting algorithm generation. We have a list containing 25 numbers, that we need to sort and figure out the greatest three numbers. However, the catch is that you can only sort 5 numbers in a single operation. So, basically imagine a function that will sort your numbers but can only take in 5 at a time. Using this function we need to be able to sort the 25 numbers to get top 3. Also, make a note of how many times the sorting function is called.

@barunthapa
barunthapa / csvWriter.go
Last active June 2, 2019 15:13
A sample program that writes to a csv file.
package main
import (
"encoding/csv"
"fmt"
"os"
"strconv"
)
var csvData = [][]string{
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<!--
Additional Styles have been added for 1,2,3,4, and 5 Bed houses
-->
<Style id="1">
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/paddle/1.png</href>
</Icon>
@barunthapa
barunthapa / duplicate_index.rb
Created July 23, 2013 11:32
Extracts the indexes of the duplicate elements including the original element
def duplicate_index(array)
size = array.size
duplicate = []
duplicate_indexes = []
array.uniq.each do |a|
duplicate_index = []
size.times do |i|
duplicate_index << i if array[i] == a
end
duplicate << duplicate_index if duplicate_index.size > 1
@barunthapa
barunthapa / csv_splitter.rb
Last active December 20, 2015 01:59
CSV Splitter
require 'csv'
file_naming_count = 0
row_count = 0
# basic file and directory naming
parent_csv_filename = "/folder/filename.csv"
csv_output_directory = "/folder/splitted/"
f=File.open(parent_csv_filename)
@barunthapa
barunthapa / bad_sliced_sheets.rb
Created July 22, 2013 09:53
Bad sliced sheets
CSV.open("bad_sliced_sheets_22july.csv", "w") do |csv|
csv << ['Sheet Id', 'Sheet url']
Sheet.bad_sliced.each do |sheet|
csv << [sheet.id, sheet.image_url]
print '.'
end
end