This file contains hidden or 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
public class Reverse { | |
public static void main(String[] args) { | |
System.out.println(reverse("Mahmoud")); | |
} | |
public static String reverse(String src) { | |
StringBuilder builder = new StringBuilder(); | |
for(int i = src.length() - 1; i >= 0; i--) { | |
builder.append(src.charAt(i)); |
This file contains hidden or 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 quicksort(lst): | |
for i in range(len(lst)): | |
for j in range(i,len(lst)): | |
if lst[i] > lst[j]: | |
lst[i], lst[j] = lst[j], lst[i] | |
return lst |
This file contains hidden or 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 toTen(x): | |
if(x < 11): | |
print x | |
toTen(x + 1) |
This file contains hidden or 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
''' | |
Created on Nov 26, 2011 | |
@author: Mahmoud | |
''' | |
def sort(seq): | |
pos = 0 | |
length = len(seq) | |
for i in seq: |
This file contains hidden or 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"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/RelativeLayout1" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:orientation="vertical" > | |
<TextView | |
android:id="@+id/tvLocation" | |
android:layout_width="wrap_content" |
This file contains hidden or 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 com.tumblr.taabouzeid.file.explorer; | |
import java.io.File; | |
import java.util.ArrayList; | |
import org.apache.commons.io.FilenameUtils; | |
import android.app.Activity; | |
import android.content.Intent; | |
import android.net.Uri; |
This file contains hidden or 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
""" | |
functions that find the biggest, smallest number or either in a list of numbers. | |
""" | |
def min_index(seq): | |
value = seq[0] | |
index = 0 | |
for i in seq: | |
if i < value: |
This file contains hidden or 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
#!/usr/bin/python2 | |
""" | |
A DNA sequence is a string made up of the letters A, T, G, and C. | |
To find the complement of a DNA sequence, As are replaced by Ts, | |
Ts by As, Gs by Cs, and Cs by Gs. For example, the complement | |
of AATTGCCGT is TTAACGGCA. | |
This function finds the complement. |
This file contains hidden or 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
import copy | |
def mating_pairs(m, f): | |
males = copy.deepcopy(m) | |
females = copy.deepcopy(f) | |
pairs = set() | |
for i in m: | |
pairs.add((males.pop(), females.pop())) | |
return pairs |
This file contains hidden or 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 find_dups(l): | |
orig = [] | |
dups = [] | |
for i in l: | |
if i in orig: | |
dups.append(i) | |
else: | |
orig.append(i) | |
return dups |