304 North Cardinal St.
Dorchester Center, MA 02124

# Digital clock CodeChef Solution

## Digital clock CodeChef Solution in C++14

``````#include <iostream>
using namespace std;

int main() {
long long t;
cin>>t;
while(t--){
long long h,m;
cin>>h>>m;
long long c=0;
for(int i=0; i<h; i++){
for(int j=0; j<m; j++){
if((i*11==j && i!=0) || (i==j*11 && j!=0) || (i==j && i<10) || (i==j && i%11==0)){
c++;
}
}
}
cout<<c<<endl;
}
return 0;
}``````

## Digital clock CodeChef Solution in PYTH 3

``````import sys
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
return(input().strip())
def invr():
return(map(int,input().split()))
def outp(n):
sys.stdout.write(str(n) + "\n")
def outlt(lst):
# outputs lst elements on a sigle line
sys.stdout.write(" ".join(map(str,lst)) + "\n")
def outplt(lst):
# outputs lst elements on seperate lines
sys.stdout.write("\n".join(map(str,lst)))
def outpltlt(lst):
# outputs lst of lst elements seperateed by space on seperate lines
sys.stdout.write("\n".join(map(str,(" ".join(map(str, a)) for a in lst))))

# ----------------------------------------------

ans = []
for _ in range(inp()):
H, M = inlt()
an = 1
for i in range(1,10):
if i < H and i < M: an += 1
if i < H and 11*i < M: an += 1
if 11*i < H and i < M: an += 1
if 11*i < H and 11*i < M: an += 1
ans.append(an)
outplt(ans)``````

## Digital clock CodeChef Solution in C

``````#include <stdio.h>

int main ()
{
int T;

scanf("%d", &T );

while (T--)

{
int H, M;

scanf( "%d%d", &H, &M );

int  nt = 1;

if ( H >= 11 )
{

for ( int i = 1; i <= 9 ; i++ )
{
if ( i <= M - 1 )

{
nt++;
}
if ( 11 * i <= M - 1 )

{
nt++;
}
}

for ( int i = 1; 11*i <= H - 1; i++ )
{
if ( i <= M - 1 )

{
nt++;
}
if ( 11 * i <= M - 1 )

{
nt++;
}
}
}
else

{
for ( int i = 1; i <= H - 1 ; i++ )
{
if ( i <= M - 1 )

{
nt++;
}
if ( 11 * i <= M - 1 )

{
nt++;
}
}
}

printf( "%d\n", nt );
}
}``````

## Digital clock CodeChef Solution in JAVA

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(System.out));
while(tt-->0){
int h=input[0], m=input[1];
int count=0;
for(int i=0;i<h;i++){
for(int j=0;j<m;j++){
String s=i+""+j;
boolean invalid=false;
for(char c: s.toCharArray()){
if(c!=s.charAt(0)){
invalid=true;
}
}
if(!invalid){
count++;
}
}
}
writer.write(count+"\n");
}
writer.flush();
}

private static int[] parseInt(String str) {
String[] parts=str.split("\\s+");
int[] ans=new int[parts.length];
for(int i=0;i<ans.length;i++){
ans[i]=Integer.parseInt(parts[i]);
}
return ans;
}

private static long[] parseLong(String str) {
String[] parts=str.split("\\s+");
long[] ans=new long[parts.length];
for(int i=0;i<ans.length;i++){
ans[i]=Long.parseLong(parts[i]);
}
return ans;
}
}``````

## Digital clock CodeChef Solution in PYPY 3

``````t=int(input())
for j in range(t):
h,m=map(int,input().split())
count=0
hour=''
min=''
for i in range(h):
hour=str(i)
for j in range(m):
min=str(j)
temp=hour+min
if(len(set(temp))==1):
count+=1
print(count)``````

## Digital clock CodeChef Solution in PYTH

``````for _ in xrange(input()):
h,m = map(int, raw_input().split())
H = h-1; M = m-1
print min(M, H, 9)+1 + min(H, M//11) + min(M, H//11) + min(H//11, M//11)``````

## Digital clock CodeChef Solution in C#

``````using System;

public class Test
{
public static void Main()
{

while (T-- > 0)
{

var h = numbers[0];
var m = numbers[1];

var count = 0;
for (int i=0;i<h;i++){

//Console.WriteLine(string.Format("-- i:{0}", i));
var hourtext = i.ToString();

//Console.WriteLine(string.Format("HourText:{0}", hourtext));

if (hourtext.Length == 2)
{
if (hourtext[0] != hourtext[1])
{
continue;

}
}

var onedig = i;
var twodigtest = string.Format("{0}{1}", i, i);

if (hourtext.Length == 2)
{
onedig = int.Parse(hourtext[0].ToString());
twodigtest = i.ToString();
}

var twodig = int.Parse(twodigtest);

if (onedig < m)
{
//Console.WriteLine(string.Format("{0}:{1}", i, onedig));
count++;
}

if (twodig< m & i>0)
{
//Console.WriteLine(string.Format("{0}:{1}", i, twodigtest));
count++;
}

}

Console.WriteLine(count);
}
}
}``````

## Digital clock CodeChef Solution in NODEJS

``````process.stdin.resume();
process.stdin.setEncoding('utf8');

var lineone = false;
input: process.stdin,
output: process.stdout,
terminal: false
});

var f=(h,m,i=10,a=1,c=(n,v,t=v,s=0)=>eval(`for(;t<n;t=''+t+v|0)s++;s`))=>eval(`for(;--i;)a+=c(h,i)*c(m,i);a`)

//console.log(f.toString().length)
rl.on('line', function(line){
if (!lineone) {
lineone = line;
} else {
param = line.split(' ').map(p => parseInt(p));
console.log(f(param[0], param[1]));
}
})

//console.log(f.toString().length);``````
##### Digital clock CodeChef Solution Review:

In our experience, we suggest you solve this Digital clock CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Digital clock CodeChef Solution.

Find on CodeChef

##### Conclusion:

I hope this Digital clock CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.

Keep Learning!