Skip to content

Instantly share code, notes, and snippets.

View r-wheeler's full-sized avatar

Ryan Wheeler r-wheeler

View GitHub Profile
@r-wheeler
r-wheeler / gist:3061c5b277b5fe468793
Created October 30, 2015 18:01
hacker rank number of deletions to make anagram
from collections import Counter
def algo(s):
if len(s) % 2 == 1:
return -1
else:
a,b = s[:len(s)/2], s[len(s)/2:]
ca = Counter(a)
cb = Counter(b)
@r-wheeler
r-wheeler / anagram.py
Created October 30, 2015 17:44
hackerrank anagram
from collections import Counter
def algo(a,b):
ca = Counter(a)
cb = Counter(b)
ct = Counter(a+b)
return sum(abs(ca[k] - cb[k]) for k in ct.keys())
a, b = raw_input(), raw_input()
@r-wheeler
r-wheeler / gist:53be8ff256913f83dfed
Created October 30, 2015 17:20
hackerrank gemstones
i = raw_input()
print len(set.intersection(*[set(raw_input()) for n in range(int(i))]))
@r-wheeler
r-wheeler / gist:8c78fcf59805a0bed2e9
Created October 30, 2015 17:12
hackerrank game of thrones
from collections import Counter
def algo(s):
v = len(filter(lambda x: x % 2 == 1, Counter(s).values()))
if v <=1:
return True
else:
return False
string = raw_input()
@r-wheeler
r-wheeler / gist:6a24715340a3710ee640
Created October 30, 2015 16:27
hackerrank alternating characters
from itertools import groupby
import operator
def algo(string):
s = list(string)
g = sum(len(list(v)) -1 for (k,v) in groupby(s, key=operator.itemgetter(0)))
return g
num = raw_input()
@r-wheeler
r-wheeler / tableau truseted
Created October 8, 2015 19:56
tableau trusted python
#! python3
import requests
import sys
# replace these with configData
tableauServer = 'http://localhost/'
tableauUsername = 'Robin'
workbookView = 'WorldIndicators/GDPpercapita'
workbookView2 = 'WorldIndicators/Countryranks'
worksheetSuffix = '.csv'
@r-wheeler
r-wheeler / Mail.scala
Created October 8, 2015 18:03 — forked from mariussoutier/Mail.scala
Sending mails fluently in Scala
package object mail {
implicit def stringToSeq(single: String): Seq[String] = Seq(single)
implicit def liftToOption[T](t: T): Option[T] = Some(t)
sealed abstract class MailType
case object Plain extends MailType
case object Rich extends MailType
case object MultiPart extends MailType
@r-wheeler
r-wheeler / gist:0d2e3d899e7b4e5a0d07
Created October 8, 2015 16:45
Tableau tabcmd on linux
Hi All,
Running on Linux is actually pretty simple. The hardest part is that you do need to be able to run either the server installer or the tabcmd installer to get the tabcmd jars. But after you do that, here are the instructions:
1) Create a local copy of C:\Program Files\Tableau\Tableau Server\9.0\extras\lib to $HOME/lib.
2) Create a ~/.tabcmd directory. This is used for logs, session storage and file uploads.
@r-wheeler
r-wheeler / vertica.scala
Created October 5, 2015 19:48
vertica scala fail
import org.apache.spark.rdd.JdbcRDD
import java.sql.{Connection, DriverManager, ResultSet}
classOf[com.vertica.jdbc.Driver]
println("com.vertica.jdbc.Driver loaded successfully ")
val conn_str = "jdbc:vertica://172.16.251.171:5433/analyticsdb?user=dbadmin&password=analytics"
// val conn = DriverManager.getConnection(conn_str)
println("Connection with vertica established ")
@r-wheeler
r-wheeler / daily.hs
Created September 21, 2015 17:36
Reddit daily programmer
import Control.Monad
import Control.Arrow
isPalandrome :: [String] -> Bool
isPalandrome = reverse >>= (==)
process :: String -> Bool
process s = isPalandrome (take n t)
where (h,t) = (head &&& tail) $ lines s
n = read h :: Int