We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 26: Nested Logic
Day 26: Nested Logic
+ 0 comments My JAVASCRIPT SOLUTION
function processData(input) { //Enter your code here let [date1, date2] = input.split('\n'); date1 = (date1.split(' ')); let [day1, month1, year1] = date1.map(e => parseInt(e));; date2 = (date2.split(' ')); let [day2, month2, year2] = date2.map(e => parseInt(e));; if(year1 < year2) { console.log('0'); } else if(year1 > year2) { console.log(10000); } else if(year1 === year2) { if(month1 < month2) { console.log('0'); } else if(month1 > month2) { console.log((month1 - month2) * 500); } else if(month1 === month2) { if(day1 < day2) { console.log('0'); } else if(day1 > day2) { console.log((day1 - day2) * 15); } else if(day1 === day2) { console.log('0'); } } } }
+ 0 comments def returned(): rd = list(map(int,input().split())) dd = list(map(int, input().split())) if rd[2] < dd[2]: return 0 elif rd[2] > dd[2]: return 10000 elif rd[1] < dd[1]: return 0 elif rd[1] > dd[1]: h = (rd[1] - dd[1]) * 500 return h elif rd[0] > dd[0]: h = (rd[0] - dd[0]) * 15 return h else: return 0 print(returned())
+ 0 comments JAVA 8 : All test cases passed.
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int d1 = sc.nextInt(); int m1 = sc.nextInt(); int y1 = sc.nextInt(); int d2 = sc.nextInt(); int m2 = sc.nextInt(); int y2 = sc.nextInt(); int fine = 0; if (y1 > y2) { fine = 10000; } else if (y1 == y2 && m1 > m2) { fine = 500 * (m1 - m2); } else if (y1 == y2 && m1 == m2 && d1 > d2) { fine = 15 * (d1 - d2); } System.out.println(fine); } }
+ 0 comments java 7 /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in); int actual_day = sc.nextInt(); int actual_month = sc.nextInt(); int actual_year = sc.nextInt(); int expected_day = sc.nextInt(); int expected_month = sc.nextInt(); int expected_year = sc.nextInt(); int fine =0; if(actual_year < expected_year) { fine = 0; } else { if(actual_year >expected_year) { fine = 10000; } else if(actual_month >expected_month) { fine = 500 *(actual_month - expected_month); } else if(actual_day >expected_day) { fine = 15 *(actual_day - expected_day); } } System.out.println(fine); }
}
+ 0 comments # Enter your code here. Read input from STDIN. Print output to STDOUT #Python 3 n=list(map(int, input().split())) #actual date x=list(map(int, input().split())) #expected date assert (1<=n[0]<=31 and 1<=n[1]<=12 and 1<=n[2]<=3000) assert (1<=x[0]<=31 and 1<=x[1]<=12 and 1<=x[2]<=3000) if n[2]>x[2]: fine=10000 elif n[1]==x[1]: if n[1]>x[1]: fine=500*(n[1]-x[1]) elif n[1]==x[1]: if n[0]>x[0]: fine=15*(n[0]-x[0]) elif n[0]<=x[0]: fine=0 else: fine=0 else: fine=0 print(fine)
Load more conversations
Sort 766 Discussions, By:
Please Login in order to post a comment