<commit_before>#! /usr/bin/python
# Penalty
#
# Computes the penalty for one homework based on a predefined value and a 
# wheight list
#
# Usage:
#   ./penalty.py upload_time deadline
#
# Input:
#   upload_time = time of upload (string)
#   deadline = assignment deadline (string)
#       date format: "dd-mm-yy hh:mm:ss"
# Output:
#   penalty_points = number of points to be substracted from the grade
#   days_late = number of days exceeding the deadline


__author__='<NAME>, <EMAIL>'


import sys
import time
import math


def parse_time(upload_time_str, deadline_str):

    # parse input strngs according to format

    upload_time = time.strptime(upload_time_str, "%d-%m-%y %H:%M:%S")
    deadline = time.strptime(deadline_str, "%d-%m-%y %H:%M:%S")

    return (upload_time, deadline)


def compute_penalty(upload_time, deadline, penalty, wheights, limit):

# penalty - for every day after the deadline the product of the penalty and 
#   the wheight is added to the penalty_points variable
# wheights - the penalty's wheight per day (the last wheight from the list 
# is used for subsequent computations)
# limit - the limit for the penalty value

    # time interval between deadline and upload time (seconds)
    interval = time.mktime(upload_time) - time.mktime(deadline)

    penalty_points = 0

    # only if the number of days late is positive (deadline exceeded)
    if interval > 0:
        days_late = int(math.ceil(interval / (3600 * 24)))
        
        for i in range(days_late):

            # the penalty exceeded the limit
            if penalty_points > limit:
                break
            else:
                # for every day late the specific wheight is used
                wheight = wheights[min(i, len(wheights) - 1)]
                penalty_points += wheight * penalty
    else:
        days_late = 0

    return (min(penalty_points, limit), days_late)


def compute_penalty_linear(upload_time, deadline):
    
    # for every day pass the deafline the penalty value is added
    # to the penalty_points
    return compute_penalty(upload_time, deadline, 0.25, [1], 3)


def compute_penalty_fixed_deadline(upload_time, deadline):

    # if the number of days pass the deadline exceeds 'x' the homework is
    # not graded (x = len(wheights) - 1)
    return compute_penalty(upload_time, deadline, 1, [1, 1, 1, 7], 10)


def compute_penalty_wheighted(upload_time, deadline):

    # the wheight for penalty is diferent depending on the day
    return compute_penalty(upload_time, deadline, 1, [1, 2, 3, 4, 0], 10)


def main():
   
    if len(sys.argv) != 3:
        print >> sys.stderr, 'Usage: %s upload_time deadline' % sys.argv[0]
        sys.exit(1)
    
    upload_time_str = sys.argv[1]
    deadline_str = sys.argv[2]

    (upload_time, deadline) = parse_time(upload_time_str, deadline_str)

    # based on the type of penalty computing used call one of 
    # the functions below
    (penalty_points, days_late) = compute_penalty_linear(upload_time, deadline)
    # (penalty_points, days_late) = compute_penalty_fixed_deadline(upload_time, deadline)
    # (penalty_points, days_late) = compute_penalty_wheighted(upload_time, deadline)
    # (penalty_points, days_late) = compute_penalty(upload_time, deadline, my_penalty, 
    #         my_wheights, my_limit)

    if penalty_points > 0:
        print "-%.2f: %d zile intarziere" % (penalty_points, days_late)    

if __name__ == '__main__':
    main()
<commit_msg>always print penalty into NOTA<commit_after>#! /usr/bin/python
# Penalty
#
# Computes the penalty for one homework based on a predefined value and a 
# wheight list
#
# Usage:
#   ./penalty.py upload_time deadline
#
# Input:
#   upload_time = time of upload (string)
#   deadline = assignment deadline (string)
#       date format: "dd-mm-yy hh:mm:ss"
# Output:
#   penalty_points = number of points to be substracted from the grade
#   days_late = number of days exceeding the deadline


__author__='<NAME>, <EMAIL>'


import sys
import time
import math


def parse_time(upload_time_str, deadline_str):

    # parse input strngs according to format

    upload_time = time.strptime(upload_time_str, "%d-%m-%y %H:%M:%S")
    deadline = time.strptime(deadline_str, "%d-%m-%y %H:%M:%S")

    return (upload_time, deadline)


def compute_penalty(upload_time, deadline, penalty, wheights, limit):

# penalty - for every day after the deadline the product of the penalty and 
#   the wheight is added to the penalty_points variable
# wheights - the penalty's wheight per day (the last wheight from the list 
# is used for subsequent computations)
# limit - the limit for the penalty value

    # time interval between deadline and upload time (seconds)
    interval = time.mktime(upload_time) - time.mktime(deadline)

    penalty_points = 0

    # only if the number of days late is positive (deadline exceeded)
    if interval > 0:
        days_late = int(math.ceil(interval / (3600 * 24)))
        
        for i in range(days_late):

            # the penalty exceeded the limit
            if penalty_points > limit:
                break
            else:
                # for every day late the specific wheight is used
                wheight = wheights[min(i, len(wheights) - 1)]
                penalty_points += wheight * penalty
    else:
        days_late = 0

    return (min(penalty_points, limit), days_late)


def compute_penalty_linear(upload_time, deadline):
    
    # for every day pass the deafline the penalty value is added
    # to the penalty_points
    return compute_penalty(upload_time, deadline, 0.25, [1], 3)


def compute_penalty_fixed_deadline(upload_time, deadline):

    # if the number of days pass the deadline exceeds 'x' the homework is
    # not graded (x = len(wheights) - 1)
    return compute_penalty(upload_time, deadline, 1, [1, 1, 1, 7], 10)


def compute_penalty_wheighted(upload_time, deadline):

    # the wheight for penalty is diferent depending on the day
    return compute_penalty(upload_time, deadline, 1, [1, 2, 3, 4, 0], 10)


def main():
   
    if len(sys.argv) != 3:
        print >> sys.stderr, 'Usage: %s upload_time deadline' % sys.argv[0]
        sys.exit(1)
    
    upload_time_str = sys.argv[1]
    deadline_str = sys.argv[2]

    (upload_time, deadline) = parse_time(upload_time_str, deadline_str)

    # based on the type of penalty computing used call one of 
    # the functions below
    (penalty_points, days_late) = compute_penalty_linear(upload_time, deadline)
    # (penalty_points, days_late) = compute_penalty_fixed_deadline(upload_time, deadline)
    # (penalty_points, days_late) = compute_penalty_wheighted(upload_time, deadline)
    # (penalty_points, days_late) = compute_penalty(upload_time, deadline, my_penalty, 
    #         my_wheights, my_limit)

    
    #if penalty_points > 0:
    print "-%.2f: %d zile intarziere" % (penalty_points, days_late)    

if __name__ == '__main__':
    main()

{'fraction_non_alphanumeric': 0.09245636809461993, 'fraction_numerical': 0.010962065483917496, 'mean_word_length': 3.2332112332112333, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3546599', 'n_tokens_mistral': 2305, 'n_tokens_neox': 2152, 'n_words': 694}