# Possible timings

Given a one/two digit timing, calculate the possibilities of occurrence of other timings(including the glowing one) with relevant to glowing segments, assuming some segments may not be glowing.

**Displaying the numbers is done using seven segment display. It is guaranteed that the sticks currently displaying are working fine.**.

**Examples:**

Input : 78 Output :5 Input :05 Output :8

**Explanation:**

**Example 1:** **7** can be replaced by **5** different numbers 9, 3, 8, 0 and 7(if none of the segment is broken) and **8** can be replaced by only **1** number i.e 8 itself(if none of the segment is broken), therefore the answer is **5*1=5**.

**Example 2:** **0** can be replaced by **2** numbers, 8 and 0, while **5** can be replaced by **4** different numbers. So, answer is **4*2=8**.

**Approach :**

Calculate for every number from **0**–**9** what all digits are possible by adding or

removing exactly one rod from the display. Store this in an array and the answer will be product of the array value of both the digits of the input.

Below is the implementation of above approach:

## C++

`// CPP program to calculate possible ` `// number of timings ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Array storing different numbers ` `// of digits a particular digit ` `// can be replaced with ` `int` `num[10] = { 2, 7, 2, 3, 3, ` ` ` `4, 2, 5, 1, 2 }; ` ` ` `// Function performing calculations ` `void` `possibleTimings(string n) ` `{ ` ` ` `cout << num[n[0] - ` `'0'` `] * ` ` ` `num[n[1] - ` `'0'` `] << endl; ` `} ` ` ` `// Driver function ` `int` `main() ` `{ ` ` ` `string n = ` `"05"` `; ` ` ` ` ` `// Calling function ` ` ` `possibleTimings(n); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to calculate ` `// possible timings. ` `import` `java.io.*; ` ` ` `class` `Calci { ` ` ` ` ` `// Array storing different ` ` ` `// numbers of digits a particular ` ` ` `// digit can be replaced with ` ` ` `static` `int` `num[] = { ` `2` `, ` `7` `, ` `2` `, ` `3` `, ` `3` `, ` ` ` `4` `, ` `2` `, ` `5` `, ` `1` `, ` `2` `}; ` ` ` ` ` `// Function performing calculations ` ` ` `public` `static` `void` `possibleTimings(String n) ` ` ` `{ ` ` ` `System.out.println(num[(n.charAt(` `0` `) - ` `'0'` `)] ` ` ` `* num[n.charAt(` `1` `) - ` `'0'` `]); ` ` ` `} ` ` ` ` ` `// Driver function ` ` ` `public` `static` `void` `main(String args[]) ` ` ` `{ ` ` ` `String n = ` `"05"` `; ` ` ` ` ` `// Calling function ` ` ` `possibleTimings(n); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python3

`# python3 program to calculate possible ` `# number of timings ` ` ` `# Array storing different numbers ` `# of digits a particular digit ` `# can be replaced with ` `num ` `=` `[ ` `2` `,` `7` `,` `2` `,` `3` `,` `3` `,` `4` `,` `2` `,` `5` `,` `1` `,` `2` `] ` ` ` `# Function performing calculations ` `def` `possibleTimings(n): ` ` ` ` ` `print` `(num[` `int` `(n[` `0` `]) ` `-` `int` `(` `'0'` `)] ` `*` `num[` `int` `(n[` `1` `]) ` `-` `int` `(` `'0'` `)] ) ` ` ` ` ` `# Driver function ` `n ` `=` `"05"` ` ` `# Calling function ` `possibleTimings(n) ` ` ` `# This code is contributed ` `# by Smitha Dinesh Semwal ` |

*chevron_right*

*filter_none*

## C#

`// C# program to calculate ` `// possible timings. ` `using` `System; ` ` ` `class` `Calci { ` ` ` ` ` `// Array storing different ` ` ` `// numbers of digits a particular ` ` ` `// digit can be replaced with ` ` ` `static` `int` `[]num = { 2, 7, 2, 3, 3, ` ` ` `4, 2, 5, 1, 2 }; ` ` ` ` ` `// Function performing calculations ` ` ` `public` `static` `void` `possibleTimings(` `string` `n) ` ` ` `{ ` ` ` `Console.WriteLine(num[(n[0] - ` `'0'` `)] ` ` ` `* num[n[1] - ` `'0'` `]); ` ` ` `} ` ` ` ` ` `// Driver function ` ` ` `public` `static` `void` `Main() ` ` ` `{ ` ` ` `string` `n = ` `"05"` `; ` ` ` ` ` `// Calling function ` ` ` `possibleTimings(n); ` ` ` `} ` `} ` ` ` `// This code is contributed by vt_m. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to calculate ` `// possible number of timings ` ` ` `// Array storing different ` `// numbers of digits a ` `// particular digit can be ` `// replaced with ` `$num` `= ` `array` `(2, 7, 2, 3, 3, ` ` ` `4, 2, 5, 1, 2); ` ` ` `// Function performing ` `// calculations ` `function` `possibleTimings(` `$n` `) ` `{ ` ` ` `global` `$num` `; ` ` ` `echo` `(` `$num` `[` `$n` `[0] - ` `'0'` `] * ` ` ` `$num` `[` `$n` `[1] - ` `'0'` `]. ` `"\n"` `); ` `} ` ` ` `// Driver Code ` `$n` `= ` `"05"` `; ` ` ` `// Calling function ` `possibleTimings(` `$n` `); ` ` ` `// This code is contributed by ` `// Manish Shaw(manishshaw1) ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

8

## Recommended Posts:

- Write a function to get the intersection point of two Linked Lists | Set 2
- Make the list non-decreasing by changing only one digit of the elements
- Count occurrences of a prime number in the prime factorization of every element from the given range
- Find two co-prime integers such that the first divides A and the second divides B
- Sum of all natural numbers from L to R ( for large values of L and R )
- Interactive Problems in Competitive Programming | Set 2
- Check if a cycle of length 3 exists or not in a graph that satisfy a given condition
- Reversing a Queue using another Queue
- Number of substrings that start with "geeks" and end with "for"
- Minimize the sum of the array according the given condition
- Nth XOR Fibonacci number
- Java | Handling TLE While Using Arrays.sort() Function
- Check which player visits more number of Nodes
- Why Should I Learn Coding?

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.