Skip to main content

CODEKATA MATHS TICKET DISCOUNT

Assume that you are ticket verifier at a club. Your club has decided to give a special discount to the person(s) who are satisfying the following condition

Condition:-
If ticket number is divisible by date of month. You are eligible for a discount.
Input Description:
First line contains input ‘n’.Next line contains n space separated numbers denoting ticket numbers .Next line contains ‘k’ date of the month.
Output Description:
Print 1 if the ticket is eligible for discount else 0
Sample Input :
6
112 139 165 175 262 130
22
Sample Output :
0 0 0 0 0 0
 
 
 
const readline = require('readline');
const inp = readline.createInterface({
  input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () => 
{var a = parseInt(userInput[0]);
 var b = userInput[1];
 var bs=userInput[1].split(" ");
 var c = parseInt(userInput[2])
 var d=[]
for(i=0;i<a;i++)
 { if(Number(bs[i])/c==0)
  d[i]=1;
 else
 d[i]=0
 }
 var e=d.join(" ")
 console.log(e);
 });
 
 
2 PRIVATE TEST CASE ERROR 

Comments

Popular posts from this blog

You are given a number ‘n’. You have to tell whether a number is great or not. A great number is a number whose sum of digits let (m) and product of digits let(j) when summed together gives the number back m+j=n

You are given a number ‘n’. You have to tell whether a number is great or not. A great number is a number whose sum of digits let (m) and product of digits let(j) when summed together gives the number back m+j=n const readline = require('readline');  const inp = readline.createInterface({   input: process.stdin  });  const userInput = [];  inp.on("line", (data) => {  userInput.push(data);  });  inp.on("close", () => {  var data = userInput[0].split(" ");  var a = parseInt(data[0]);  var b= String(a);  var c=[] for(i=0;i<b.length;i++)     {c[i]=b[i]}  var sum=0; for(i=0;i<c.length;i++) {sum=sum+Number(c[i])} var product=1; for(i=0;i<c.length;i++) {product=product*Number(c[i])} var d=sum+product if(d==a) console.log("Great");    else  console.log("no"); });

Given a number N, print yes if the number is a multiple of 7 else print no.

Given a number N, print yes if the number is a multiple of 7 else print no. const readline = require('readline');  const inp = readline.createInterface({   input: process.stdin  });  const userInput = [];  inp.on("line", (data) => {  userInput.push(data);  });  inp.on("close", () => {  var data = userInput[0].split(" ");  var a = parseInt(data[0]);  if(a%7==0)  console.log("yes")  else  console.log("no") });

Given 2 numbers N,M. Find their difference and check whether it is even or odd.

Given 2 numbers N,M. Find their difference and check whether it is even or odd. const readline = require('readline');  const inp = readline.createInterface({   input: process.stdin  });  const userInput = [];  inp.on("line", (data) => {  userInput.push(data);  });  inp.on("close", () => {  var data = userInput[0].split(" ");  var a = parseInt(data[0]);  var b = parseInt(data[1]); var c=(a-b) var d=Math.abs(c) if(d%2==0)  console.log("even")  else  console.log("odd") });