Skip to content

Commit 82b010e

Browse files
author
nukala.akhil
committed
Added some comments
1 parent 8b27b35 commit 82b010e

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
lines changed

pset1/credit.c

+19
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ int main(void)
1010
long long num = get_long_long();
1111

1212
int total = 0;
13+
// check fo valid digits
1314
if (validNumDigits(num))
1415
{
16+
// check for the conditions given in the spec
1517
total = getSum(num);
1618
if (total % 10 == 0)
1719
{
@@ -48,9 +50,13 @@ int main(void)
4850
}
4951
}
5052

53+
/*
54+
return whether card has valid num of digits
55+
*/
5156
bool validNumDigits(long long num)
5257
{
5358
int count = 0;
59+
5460
while (num > 0)
5561
{
5662
count++;
@@ -66,12 +72,21 @@ bool validNumDigits(long long num)
6672
}
6773
}
6874

75+
/*
76+
return the sum of the credit card
77+
alternate digits are multiplied by 2
78+
*/
6979
int getSum(long long num)
7080
{
81+
7182
int sum = 0;
83+
84+
// maintain count for alternating
7285
int count = 1;
86+
7387
while (num > 0)
7488
{
89+
// if alternate...if (num > 4) ==> 5*2 = 10 ==> sum=1 similary remaining
7590
if (count % 2 == 0)
7691
{
7792
int rem = num % 10;
@@ -105,7 +120,11 @@ int getSum(long long num)
105120
int rem = num % 10;
106121
sum += rem;
107122
}
123+
124+
// count from right to left
108125
num = num/10;
126+
127+
109128
count++;
110129
}
111130
return sum;

pset5/speller/dictionary.c

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void release(node *ptr);
3333
bool check(const char *word)
3434
{
3535
node *trav = root;
36+
// for each letter in the word
3637
for (int i = 0, n = strlen(word); i< n; i++)
3738
{
3839
if (word[i] == '\'')
@@ -59,6 +60,7 @@ bool check(const char *word)
5960
}
6061

6162
}
63+
// check whether the isword is true
6264
if (trav->isword == true)
6365
{
6466
return true;
@@ -157,6 +159,7 @@ bool unload(void)
157159
void release(node *ptr)
158160
{
159161
node *parent = ptr;
162+
// recursively release the node...back-tracking
160163
for (int i = 0; i < 27; i++)
161164
{
162165
if (ptr->character[i] != NULL)

pset6/sentiments/analyzer.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Analyzer():
55

66
def __init__(self, positives, negatives):
77
"""Initialize Analyzer."""
8+
# open positives and add to the positives set
89
self.positives = set()
910
self.negatives = set()
1011
with open(positives) as lines:
@@ -13,22 +14,24 @@ def __init__(self, positives, negatives):
1314
clean = line.strip()
1415
if clean:
1516
self.positives.add(clean.lower())
17+
# open negatives and add to the negatives set
1618
with open(negatives) as lines:
1719
for line in lines:
1820
if not line.startswith(';'):
1921
clean = line.strip()
2022
if clean:
2123
self.negatives.add(clean.lower())
2224

23-
# TODO
25+
2426

2527
def analyze(self, text):
2628
"""Analyze text for sentiment, returning its score."""
27-
28-
# TODO
29+
30+
# break into tokens
2931
tokenizer = nltk.tokenize.TweetTokenizer()
3032
tokens = tokenizer.tokenize(text)
3133
tot = 0
34+
# count the total score
3235
for token in tokens:
3336
if token.lower() in self.positives:
3437
tot += 1

pset6/sentiments/application.py

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def search():
4141
negative += 1
4242
else:
4343
neutral += 1
44-
# TODO
4544

4645

4746
# generate chart

pset8/mashup/application.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ def index():
3232
@app.route("/articles")
3333
def articles():
3434
"""Look up articles for geo."""
35-
36-
# TODO
35+
# simple just read and understand the given code and API
3736
geo = request.args.get("geo")
3837
if not geo:
3938
raise RuntimeError("missing geo")
@@ -44,7 +43,10 @@ def articles():
4443
@app.route("/search")
4544
def search():
4645
"""Search for places that match query."""
46+
# simple remember error checking
4747
q=request.args.get("q")
48+
if not q:
49+
raise RuntimeError("missing query")
4850
rows=db.execute("SELECT * FROM places WHERE (postal_code LIKE :id) OR (place_name LIKE :id) OR (admin_name1 LIKE :id)", id=q+'%')
4951
return jsonify(rows)
5052

pset8/mashup/static/scripts.js

+6
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,27 @@ function addMarker(place)
7272
title: place.place_name
7373
});
7474

75+
// read the code...and understand ..get hints from configure and show info
7576
marker.addListener('click', function() {
7677
$.getJSON(Flask.url_for("articles"), {geo: place.postal_code})
7778
.done(function(data, textStatus, jqXHR) {
7879
var content='<ul>';
80+
// error checking not done..because...some news will be there!!!...
7981
for (var i = 0; i < data.length; i++){
8082
content += '<li>';
8183
content += "<a href="+data[i].link+">"+data[i].title+"</a>";
8284
content += '</li>'
8385
}
8486
content += '</ul'
87+
// show the content
8588
showInfo(marker, content)
8689
});
8790
});
8891

92+
// add to the markers list
8993
markers.push(marker)
94+
95+
// show the maker
9096
marker.setMap(map)
9197
}
9298

0 commit comments

Comments
 (0)