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 java.util.Arrays; | |
public class BubbleSort { | |
public static void main(String[] args){ | |
int[] numbers = {9, 2, 7, 4, 6}; | |
int[] sorted = sort(numbers); | |
System.out.println(Arrays.toString(sorted)); | |
} | |
public static int[] sort(int[] input){ |
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 Bottles { | |
public static void main (String args[]) { | |
String lyrics = "%1$d bottles of beer on the wall, %1$d bottles" + | |
" of beer.\nTake one down and pass it around, %2$d bottles of" + | |
" beer on the wall.\n"; | |
String lyricsTwo = "%1$d bottle of beer on the wall, %1$d bottle" + | |
" of beer.\nTake one down and pass it around, %s bottles of beer" + | |
" on the wall.\n"; | |
String lyricsOne = "%1$d bottle of beer on the wall, %1$d bottle" + |
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 |
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
#!/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
""" | |
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
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
<?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
''' | |
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
def toTen(x): | |
if(x < 11): | |
print x | |
toTen(x + 1) |
OlderNewer