Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
commentSymbol = "//"

import sys
import os, os.path

acceptableFileExtensions = sys.argv[1:]
if not acceptableFileExtensions:
print('Please pass at least one file extension as an argument.')
quit()

currentDir = os.getcwd()

filesToCheck = []
for root, _, files in os.walk(currentDir):
for f in files:
fullpath = os.path.join(root, f)
if '.git' not in fullpath:
for extension in acceptableFileExtensions:
if fullpath.endswith(extension):
filesToCheck.append(fullpath)

if not filesToCheck:
print('No files found.')
quit()

lineCount = 0
totalBlankLineCount = 0
totalCommentLineCount = 0

print('')
print('Filename\tlines\tblank lines\tcomment lines\tcode lines')

for fileToCheck in filesToCheck:
with open(fileToCheck) as f:

fileLineCount = 0
fileBlankLineCount = 0
fileCommentLineCount = 0

for line in f:
lineCount += 1
fileLineCount += 1

lineWithoutWhitespace = line.strip()
if not lineWithoutWhitespace:
totalBlankLineCount += 1
fileBlankLineCount += 1
elif lineWithoutWhitespace.startswith(commentSymbol):
totalCommentLineCount += 1
fileCommentLineCount += 1




print('')
print('Totals')
print('--------------------')
print('Lines: ' + str(lineCount))
print('Comment lines: ' + str(totalCommentLineCount))
print('Code lines: ' + str(lineCount - totalBlankLineCount - totalCommentLineCount))



6 changes: 6 additions & 0 deletions data1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
asdadaas
//asdsas
asdsadsfdv
//adsas
//aasdds

26 changes: 26 additions & 0 deletions sunday.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import time
from math import floor

"""
Gaussian algorithm to determine day of week
"""
def day_of_week(year, month, day):
d = day
m = (month - 3) % 12 + 1
y = year % 100
c = (year - (year % 100)) / 100

w = (d + floor(2.6 * m - 0.2) + y + floor(y/4) + floor(c/4) - 2*c) % 7

return int(w)

"""
Compute the number of months starting on a given day of the week in a century
"""
def months_start_range(day,year_start,year_end):
total = 0
for year in range(year_start, year_end + 1):
for month in range(1,13):
if day_of_week(year, month, 1) == day: total += 1
#return total
print(total)