Skip to content

Instantly share code, notes, and snippets.

View 8bit-pixies's full-sized avatar

8bit-pixies

  • Nowhere
View GitHub Profile
@8bit-pixies
8bit-pixies / 002sas
Created November 25, 2012 03:32
002sas
/*
Program: Get all possible Permutations of a known number of words in a string
Author: Chapman Siu
Description:
Using proc plan and proc transpose, a data set is generated which has all possible
permutations.
Then a macro is writen to allow text to be scanned and concatenate to form a new string.
*/
@8bit-pixies
8bit-pixies / chall113.py
Created November 25, 2012 04:15
chall113
import re
from string import strip
def blueS(string):
if re.search("^\d+\.\d+$",strip(string)):
return 'float'
elif re.search("^\d\d-\d\d-\d{4}$",strip(string)):
return 'date'
elif re.search("^[-+]?\d+$",strip(string)):
return 'int'
@8bit-pixies
8bit-pixies / day1.rb
Last active October 13, 2015 19:18
Seven Languages in Seven Weeks - Ruby Day 1 Day 2
#day1 questions
puts "Hello, world"
puts "Hello, Ruby".index("Ruby")
x=0
while x < 10
puts "Chapman"
x = x + 1
end
dict = File.open('selected_four-letter_words.txt').map {|word| word.chomp}
#grab the two words so that you know what you're comparing with!
def one_letter(input,dict)
output = []
dict.each do |word|
letterDiff = 0
word.split('').to_enum.with_index {|letter,i| letterDiff = letterDiff+1 if letter == input[i]}
output << word if letterDiff == 3
@8bit-pixies
8bit-pixies / regex.sas
Created December 14, 2012 08:50
regex example showing one possible way of dealing with "unstructured-like" data within SAS.
data test;
input a $1-200;
cards;
Organisation trades in a high risk country China, [JURIS: CHN] and is
also involed in charity [INDUSTRY: CHARITY]. Customers acquisition
date is [ACQUISITION_DATE: 10JUL1999]
Customer A is a [JOB: SOLE TRADER]
;
run;
#!/usr/bin/python
##############################################################################
# Emilio Schapira
# Copyright (C) 2003 Advanced Interface Technologies, Inc.
# http://www.advancedinterfaces.com
# http://sourceforge.net/projects/pycron/
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
@8bit-pixies
8bit-pixies / chall74.rb
Created December 27, 2012 09:27
challenge 74
#chall 74 in ruby
#zeckendorf representation
def fib_seq(m)
#get array of fibonacci seq up to a certain number
seq = [1,1]
until seq[-1] > m do
seq.push(seq[-1]+seq[-2])
end
@8bit-pixies
8bit-pixies / chall80.rb
Created December 27, 2012 09:52
challenge 80
#chall80
#anagrams - no bonus
#idea, each word will have a 'fingerprint' by alphabetical ordering of the word
def anagram(m)
File.open('enable1.txt').map {|word|
word.chomp.chars.sort.join == m.chars.sort.join ? word.chomp : nil
}.compact
end
@8bit-pixies
8bit-pixies / chall115.rb
Created January 6, 2013 07:01
chall115
def guess_rank
x=rand(100)+1
print "Guess number between 1-100: "
guess = x+1
while x!=guess
guess = gets.to_i
puts "lower" if x<guess
puts "higher" if x>guess
puts "correct" if x==guess
end
@8bit-pixies
8bit-pixies / tangledpython.py
Created January 28, 2013 05:49
tangledpython
#module to do a clean up for tangle.js
import markdown
import re
import ast
import yaml
import jinja2
import os
"""