rohshall


Joined 8 months ago
Homeworks submitted:
Homework comments:
44
1

About Me

I am an experienced programmer, with C/C++, Java and Python experience.

Classes

Learning Web Programming using Javascript

Class status: Under Construction
Role: Creator
. 0% complete

Fast-track Java

Class status: Under Construction
Role: Creator
. 100% complete

Learning Shell Scripting

Class status: Under Construction
Role: Creator
. 100% complete

Intermediate C++

Class status: Under Construction
Role: Creator
. 87% complete

Learning to speak Chinese

Class status: Under Construction
Role: Creator
. 100% complete

Learn You a Haskell

Class status: Under Construction
Role: Creator
. 85% complete

Programming Clojure

Class status: Under Construction
Role: Creator
. 100% complete

Programming Scala

Class status: Under Construction
Role: Creator
. 100% complete

Programming Ruby

Class status: Under Construction
Role: Creator
. 100% complete

Reddit Learns Programming

Class status: Under Construction
Role: Student
. 0% complete

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming

Class status: Established
Role: Student
. 23% complete

How to develop an Android app

Class status: Under Construction
Role: Student
. 0% complete

Submitted Assignments

Learning to speak Chinese: Lesson 2, HW 1

Zhe shi wo de ma ma
Zhe shi wo de ba ba


rohshall 7 months ago
Learning to speak Chinese: Lesson 1, HW 1

wo shi salil.
wo sanshi wu sue le.


rohshall 7 months ago
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 3, HW 1

LIMIT = 200

def is_diophantine_num(n, pack_sizes): ''' It is diophantine number if we can find non-negative numbers a, b and c such that: p1 * a + p2 * b + p3 * c = n. ''' p1, p2, p3 = pack_sizes options = range(int(n / p1) + 1) result = [(a, b, c) for a in options for b in options for c in options if p1 * a + p2 * b + p3 * c == n] #print "a,b,c for {0}: {1}".format(n, result) return bool(result)

def find_largest_nondiophantine_num(pack_sizes): smallest_possible_diophantine = pack_sizes[0] largest_nondiophantine = smallest_possible_diophantine - 1 count_diophantine = 0 for n in xrange(smallest_possible_diophantine, LIMIT): if is_diophantine_num(n, pack_sizes): count_diophantine += 1 if count_diophantine == smallest_possible_diophantine: return largest_nondiophantine else: count_diophantine = 0 largest_nondiophantine = n

if name == 'main': pack_sizes = (6, 9, 20) print "largest non diophantine num for pack sizes {0} is {1}".format( pack_sizes, find_largest_nondiophantine_num(pack_sizes))


rohshall 7 months ago
Bash Scripting: Lesson 5, HW 1

/usr/bin/env sh

re="([a-zA-Z ]) - ([0-9]) - (.*)$"

while read cdtrack; do if [[ "$cdtrack" =~ $re ]]; then echo Track ${BASH_REMATCH[2]} is ${BASH_REMATCH[3]} fi done < tracks.txt

The cookbook does not say this because it predates the version 3.2, but using quotes in RHS in =~ makes it a string comparison rather than a regex match. That is why RE needs to be stored in a variable first.


rohshall 8 months ago
Bash Scripting: Lesson 4, HW 1

F1NAME=${1:-/bin/ls -l} F2NAME=${2:-assignment.sh}

$F1NAME "$F2NAME"


rohshall 8 months ago
Bash Scripting: Lesson 3, HW 1

/usr/bin/env sh

for SCRIPT in /sbin/*; do if [ -f $SCRIPT -a -x $SCRIPT ]; then echo "$SCRIPT" fi done


rohshall 8 months ago
Programming in C: Lesson 1, HW 1

include

int main() { printf("Hello Worldc"); return 0; }

I got:

assignment.c: In function ‘main’: assignment.c:4:10: warning: unknown escape sequence: 'c'


rohshall 8 months ago
Bash Scripting: Lesson 2, HW 1

/usr/bin/env sh

function choose { read -p "Would you give me your password? (y/n): " answer case $answer in [yY] ) echo "you are a darling" read -s -p "password: " password printf "n" ;; [nN] ) echo "You are angry with me" ;; * ) echo "Hmm...." ;; esac }

choose

if [ -n "$password" ]; then echo "Your password is:" $password fi


rohshall 8 months ago
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 2, HW 1

import math import itertools

def isPrime(num): limit = int(math.sqrt(num)) for i in xrange(2, limit+1): if num%i == 0: return False return True

def primes(): yield 2 num = 3 while True: if isPrime(num): yield num num += 2

print 1000th number

thousandth = next(itertools.islice(primes(), 999, 1000)) print thousandth

def primes_with_sum_of_logs(): yield 2, 0 num = 3 sum_of_logs = 0 while True: if isPrime(num): yield num, sum_of_logs sum_of_logs += math.log(num) num += 2

for num, sum_of_logs in itertools.islice(primes_with_sum_of_logs(), 1000): print num, sum_of_logs, sum_of_logs / num


rohshall 8 months ago
MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming: Lesson 1, HW 1
  • firstname = raw_input("Enter your first name: ")
  • lastname = raw_input("Enter your last name: ")
  • print "Your name is: ", firstname, lastname

rohshall 8 months ago