Skip to content

Instantly share code, notes, and snippets.

Python 2.7.5 |Anaconda 1.6.1 (x86_64)| (default, Jun 28 2013, 22:20:13)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 'abc'[1]
'b'
>>> 'abc'[1] = 'c'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignment
>>> array = ['dog', 'cat', 'duck']
@podopie
podopie / gist:1308147
Last active September 27, 2015 17:48
sum0=0;
sum1=0;
for i=1:m,
sum0=sum0+(theta(1)+theta(2)*X(i,2))-y(i);
sum1=sum0*X(i,2);
end
temp0=theta(1)-(alpha/m)*sum0;
temp1=theta(2)-(alpha/m)*sum1;
@podopie
podopie / superbranching.rb
Created June 24, 2011 04:55
using || operator to determine sequencing
def find_sequence goal
def find start, history, goal
if start == goal
history
elsif start > goal
nil
else
find(start + 5, '(' + history + ' + 5)', goal) || find(start * 3, '(' + history + ' * 3)', goal)
end
end