Thales Coding Questions and Answers
Thales Coding Questions with Solutions
On this page, you will get Thales Coding Questions and Answers asked in Online Assessment and Coding – Technical Interview involved Thales Recruitment Process.
Apart from this, you will get other details like Job profiles, Job Locations, CTC Offered, and specific steps of the Recruitment Process.
About Thales
Thales was founded in 1968, and earlier it was named Thomson – CSF, is a French MNC that designs and manufactures electronic devices and equipment for defense, aerospace, transportation, security, and surveillancerelated Organizations.
In 1999, Thales and Samsung Electronics created a Joint Venture and started manufacturing Electronic Equipments together.
Thales Recruitment Process
The recruitment process mainly consists of 3 processes :
 Online Assessment [ Aptitude + Logical + Verbal + Coding ]
 Technical Interview
 HR Interview
We have mentioned further details of the Thales Recruitment Process in the following Tabular Form
Thales  Related Information 

Position :  Software Engineer – Support 
Course : 

Eligibility Criteria / Academic Qualification Required : 

Cost to Company (CTC) 

Selection Process : 

Joining Location :  Noida 
 Computer Science Fundamentals.
 Data Structures & Algorithms.
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Thales Coding Questions and Answers
Question 1: Consecutive Prime Sum
Problem Description
Question – : Some prime numbers can be expressed as a sum of other consecutive prime numbers.
 For example
 5 = 2 + 3,
 17 = 2 + 3 + 5 + 7,
 41 = 2 + 3 + 5 + 7 + 11 + 13.
Your task is to find out how many prime numbers which satisfy this property are present in the range 3 to N subject to a constraint that summation should always start with number 2.
Write code to find out the number of prime numbers that satisfy the abovementioned property in a given range.
Input Format: First line contains a number N
Output Format: Print the total number of all such prime numbers which are less than or equal to N.
Constraints: 2<N<=12,000,000,000
#include <stdio.h> int prime(int b); int main() { int i,j,n,cnt,a[25],c,sum=0,count=0,k=0; printf("Enter a number : "); scanf("%d",&n); for(i=2;i<=n;i++) { cnt=1; for(j=2;j<=n/2;j++) { if(i%j==0) cnt=0; } if(cnt==1) { a[k]=i; k++; } } for(i=0;i<k;i++) { sum=sum+a[i]; c= prime(sum); if(c==1) count++; } printf(" %d",count); return 0; } int prime(int b) { int j,cnt; cnt=1; for(j=2;j<=b/2;j++) { if(b%j==0) cnt=0; } if(cnt==0) return 1; else return 0; }
Output Enter a number : 43 4
#include <iostream> using namespace std; int prime(int b) { int j,cnt; cnt=1; for(j=2;j<=b/2;j++) { if(b%j==0) cnt=0; } if(cnt==0) return 1; else return 0; } int main() { int i,j,n,cnt,a[25],c,sum=0,count=0,k=0; cout<<"Enter a number : "; cin>>n; for(i=2;i<=n;i++) { cnt=1; for(j=2;j<=n/2;j++) { if(i%j==0) cnt=0; } if(cnt==1) { a[k]=i; k++; } } for(i=0;i<k;i++) { sum=sum+a[i]; c= prime(sum); if(c==1) count++; } cout<<count; return 0; }
Output Enter a number : 5 1
import java.util.Scanner; class Main { static int prime(int b) { int j,cnt; cnt=1; for (j = 2; j <= b/2; j++) { if(b%j==0) cnt=0; } if(cnt==0) return 1; else return 0; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i,j,n=0,cnt,c=0,sum=0,count=0,k=0; Main t = new Main(); int[] a = new int[25]; System.out.println("Enter no"); n = sc.nextInt(); for (i = 2; i <=n ; i++) { cnt=1; for (j = 2; j <= n/2; j++) { if(i%j==0) cnt=0; } if(cnt==1) { a[k]=i; k++; } } for (i = 0; i < k; i++) { sum=sum+a[i]; c=t.prime(sum); if(c==1) count++; } System.out.println(count); } }
Output 43 4
num = int(input()) arr = [] sum = 0 count = 0 if num > 1: for i in range(2, num + 2): for j in range(2, i): if i % j == 0: break else: arr.append(i) def is_prime(sum): for i in range(2, (sum // 2) +2): if sum % i == 0: return False else: return True for i in range(0, len(arr)): sum = sum + arr[i] if sum <= num: if is_prime(sum): count = count + 1 print(count)
Output 20 2
Question 2 : Reach the Channel
Problem Statement – Sahil watches TV all day and gets bored. He started playing this dumb game of identifying minimum number of inputs needed to reach a channel. As his cousin, you have to help him, but you live far from his house. So you decide to write a code that will ask Sahil for some inputs and give outputs respectively.
Here are the problems you need to keep in mind,
 There are 13 buttons on his remote: 10 buttons for the numbers (09) to form integers denoting respective channel index, “Up channel” button and “ Down channel” button for going i +1th channel and i1th channel from i respectively, and a “Last viewed” button to see what’s the last channel before it.
 The number buttons allow you to jump directly to a specific channel (Ex: to go to channel 172 by typing 1,7,2).
 If the channel which you are in is ith and that is the max channel index possible, by Up channel, you will reach the first channel possible. Same goes for the down channel button. You can go to the highest channel possible if you go down from the lowest channel possible.
Sahil can get from one channel to the next in one of the two ways.
Sahil’s parents have set some parental control on some channels on Aniruth’s television. The “Up Channel “ and “Down buttons” buttons skip these channels as these channels are not viewable.
Given a list of channels to view, the lowest channel, the highest channel, and a list of blocked channels, your program should return the minimum number of clicks necessary to get through all the shows that Anirudh would like to match.
Input Format
 First line is the lowest Channel
 Secondline is the highest Channel
 Followed by a number of blocked channels B,
 and the next B lines contain the actual blocked channels.
 Followed by the number of Channels to view V, and the next V lines contain the actual channels to view.
Constraints
 The lowest channel on the television will be greater than 0. and less than or equal to 10,000.
 The highest channel on the television will be greater than or equal to the lowest channel. and less than or equal to 10.000.
 The list of channels that are blocked on Anirudh’s television. All the channels in this list will be valid channels (greater than or equal to lowest channel, less than or equal 1 to highest channel). Duplicates may be Ignored. The blocked list can be a maximum of 40 channels.
 The sequence that Sahil must view contains between 1 and 50 elements. inclusive. All channels in this sequence are not in the blocked list and are between lowest channel and highest channel. Inclusive.
Sample Input 0:
1
20
2
18
19
5
15
14
17
1
17
Sample output 0:
7
#include<bits/stdc++.h> using namespace std; unordered_mapm; int l,u; int util(int a,int b) { if(a==b) return 0; if(m[a]) return util(a+1,b); return 1+util(a+1,b); } int func(int b,int prev) { if(b >l>>u; int bn,b; cin>>bn; while(bn){ cin>>b;m[b]++; } cin>>bn; while(bn) { cin>>b; if(b>9 && flag==0) {ans+=2;flag++;prev=b;} else if(flag==0) {ans+=1;flag++;prev=b;} else if(prev2==b) {prev2=prev;prev=b;ans++;} else { ans+=min(b>9?2:1,func(prev,b));prev2=prev;prev=b; } } cout<< ans; }
import java.util.*; public class GameOfClicks { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int l=sc.nextInt(); int h=sc.nextInt(); int b=sc.nextInt(); Listbl=new ArrayList<>(); for(int i=0;i<b;i++){ bl.add(sc.nextInt()); } int v=sc.nextInt(); Listvl=new ArrayList<>(); for(int i=0;i<v;i++){ vl.add(sc.nextInt()); } Setsl=new HashSet<>(); int res=0; for(Integer i:vl){ if(bl.contains(i)) continue; sl.add(i); } for(Integer i:sl){ String s=i+""; res+=s.length(); } System.out.println(res); } }
def prev(now,l,h,blocked): if now!=l: if (now1) not in blocked: return (now1) else: return prev(now1,l,h,blocked) else: if h not in blocked: return h else: return prev(h,l,h,blocked) def next(now,l,h,blocked): if now!=h: if (now+1) not in blocked: return (now+1) else: return next(now+1,l,h,blocked) else: if l not in blocked: return l else: return next(l,l,h,blocked) def digits(n): count=0 while n>0: n=n//10 count+=1 return count for i in range(2): if i==0: l=int(input()) else: h=int(input()) b=int(input()) blocked=[] for i in range(b): blocked.append(int(input())) back=1 now=1 c=int(input()) k=0 for i in range(c): n=int(input()) n1=digits(n) if now==1: now=n k+=n1 continue if back==n: k+=1 back,now=now,back continue pf=0 pb=0 now1=now prev1=now for j in range(n1): if j==(n11): pf=n1 pb=n1 break else: now1=next(now1, l, h, blocked) pf+=1 prev1=prev(prev1, l, h, blocked) pb+=1 if now1==n: break if prev1==n: break k+=pf back=now now=n print(k)
Question 3 : Find the Siblings
Henry is extremely keen on history and every one of the ages of his family. He does a ton of exploration and understands that he has plummeted from the incomparable Amaya line. After a ton of looking through old records and the most recent records of the general public, he can discover all the parentkid connections in his family right from the extraordinary ruler Ming of the tradition to himself.
These connections are given in the structure a direct exhibit where emperor is at the main position and his kids are at pos (2i + 1) and (2i + 2)
This is the pattern followed throughout.
Henry needs to sort out every one of the kin of individual X from the information.
Write a program for Henry to figure out all the siblings of person X from the data.
Return the sorted list of all of Henry’s siblings.
If no sibling return {1}
 input 1: N, the length of the array
 input2: An array representing the ancestral tree
 input 3 : X, the person whose siblings are sought.
 output – return the array of all siblings in increasingly sorted order.
Example 1 :
input 1 : 5
input 2 : {1,2,3,4,5}
input 3 : 1
output : {1}
Explanation : x is the root of the tree and has no siblings
Example 2 :
input 1 : 6
input 2 : {1,2,3,4,5,6}
input 3 : 5
output : {4,6}
Explanation : {2,3 } are the children of {1}.
{4,5,6 } are the children of {2,3}, thus the siblings of x= 5 are {4,6}
import java.util.*; public class Main { Node root; static class Node { int data; Node left, right; Node (int data) { this.data = data; this.left = null; this.right = null; } } public static void main (String[]args) { Main t2 = new Main (); Scanner sc = new Scanner (System.in); int length = sc.nextInt (); int arr[] = new int[length]; for (int i = 0; i < length; i++) { arr[i] = sc.nextInt (); } int target = sc.nextInt (); t2.root = t2.insertLevelOrder (arr, t2.root, 0); Set < Integer > sets = t2.levelOrderBottom (t2.root, target); sets.remove (target); System.out.println (sets); } public static Node insertLevelOrder (int[]arr, Node root, int i) { if (i < arr.length) { Node temp = new Node (arr[i]); root = temp; root.left = insertLevelOrder (arr, root.left, 2 * i + 1); root.right = insertLevelOrder (arr, root.right, 2 * i + 2); } return root; } public Set < Integer > levelOrderBottom (Node root, int target) { if (root == null) { return null; } Queue < Node > q = new LinkedList <> (); q.offer (root); while (!q.isEmpty ()) { int qsize = q.size (); Set < Integer > temp = new HashSet <> (); for (int i = 0; i < qsize; i++) { Node child = q.poll (); temp.add (child.data); if (child.left != null) { q.offer (child.left); } if (child.right != null) { q.offer (child.right); } } if (temp.contains (target)) return temp; } return null; } }
def identify_siblings(tree_array, x): tree_len = len(tree_array) index = tree_array.index(x) level = 0 start_index = level number_of_nodes = 0 while start_index < tree_len: end_index = pow(2, level) + start_index if x in tree_array[start_index:end_index]: break level += 1 start_index = (2 * start_index) + 1 final_array = tree_array[start_index:end_index] final_array.remove(x) return final_array if final_array else [1]
Question 4 : Total Distance Covered by the Beetle
Problem Description
A 10cm x 10cm x 10cm solid cube rests on the ground. It has a beetle on it, as well as some sweet honey spots on the cube’s surface. The beetle begins at a point on the cube’s surface and moves in a clockwise direction along the cube’s surface to the honey spots.
 If it goes from one point on the same face to another (say, X to Y), it goes in an arc of a circle that subtends an angle of 60 degrees at the circle’s center.
 If it travels from one point to another on a different face, it takes the shortest path on the cube’s surface, except that it never travels along its bottom.
The beetle is a Cartesian geometry student who knows the coordinates (x, y, z) of all the points it needs to visit. Its coordinate origin is one of the cube’s corners on the ground, and the zaxis points up. As a result, z=0 is the bottom surface (on which it does not crawl), and z=10 is the top. The beetle keeps track of all distances traveled and rounded the distance to two decimal places when it arrives at the following location so that the final distance is a sum of the rounded distances from spot to spot.
Input
The first line returns an integer N, the total number of points visited by the beetle (including the starting point).
The second line contains 3N nonnegative numbers, each with two decimal places. These are to be interpreted as the x, y, and z coordinates of the points the beetle must visit in the given order.
Output
One line containing a number representing the total distance traveled by the beetle to two decimal places. Even if the travel distance is an integer, the output should have two decimal places.
Constraints
None of the points visited by the beetle are on the bottom face (z=0) or on any of the cube’s edges (the lines where two faces meet)
2<=N<=10
Example
Input : 31 1 10 2 1 10 0 1 9
Output : 4.05
Explanation :The beetle visits three different locations (N=3). The beetle begins on the cube's top face (z=10) at point (1,1,10) and moves to another point on the same face (2,1,10). Although the straight line distance is one, it travels on the arc of a circle with an angle of 60 degrees at its center and thus travels (2*pi)/6 or 1.05 (note that it rounds the distance at each leg of the journey). It moves along the cube's surface from (2,1,10) on the face z=10 to (0,1,9) on the face x=0. This is a threemile distance. The total travel distance is 1.05+3=4.05. The result is 4.05
#include <stdio.h> #include <conio.h> #define PIE 3.14 int s_x,s_y,s_z; float shortDist(int x, int y, int z) { float dis; // check if the Zaxis and any other one axis are the same. if(z == s_z && ( y == s_y  x == s_x) && s_z != 0) { //check if the x axis of next coordinate is same if(x != s_x) dis = (2 * PIE * (abs(xs_x)))/6.0; //check if the y axis of next coordinate is same else dis = (2 * PIE * (abs(ys_y)))/6.0; } // finddistance between x and y and the abs distance of Z axis else dis = (int)(sqrt(pow(xs_x,2) + pow(ys_y,2)) + abs(zs_z)); s_x = x; s_y = y; s_z = z; return dis; } int main() { int n; scanf("%d", &n); n = 3 * n; int arr[n]; for(int i = 0;i < n;i++) scanf("%d", &arr[i]); float sum = 0.0; s_x = arr[0]; s_y = arr[1]; s_z = arr[2]; for(int i=3;i<n;i+=3) { sum += shortDist(arr[i],arr[i+1],arr[i+2]); } printf("%.2f",sum); }
#include<bits/stdc++.h> using namespace std; #define PIE 3.14 int s_x,s_y,s_z; float shortDist(int x, int y, int z) { float dis; // check if the Zaxis and any other one axis are the same. if(z == s_z && ( y == s_y  x == s_x) && s_z != 0) { //check if the x axis of next coordinate is same if(x != s_x) dis = (2 * PIE * (abs(xs_x)))/6.0; //check if the y axis of next coordinate is same else dis = (2 * PIE * (abs(ys_y)))/6.0; } // finddistance between x and y and the abs distance of Z axis else dis = (int)(sqrt(pow(xs_x,2) + pow(ys_y,2)) + abs(zs_z)); s_x = x; s_y = y; s_z = z; return dis; } int main() { int n; cin>>n; n = 3 * n; int arr[n]; for(int i = 0;i < n;i++) cin>>arr[i]; float sum = 0.0; s_x = arr[0]; s_y = arr[1]; s_z = arr[2]; for(int i=3;i<n;i+=3) { sum += shortDist(arr[i],arr[i+1],arr[i+2]); } printf("%.2f",sum); }
import java.util.*; import java.lang.*; import java.io.*; class Main{ final static float PIE = 3.14f; static int s_x, s_y, s_z; public static void main(String[] args) { int i, N, x, y, z; int arr[] = new int[50]; float sum = 0.0f; Scanner sc = new Scanner(System.in); N = sc.nextInt(); N = 3 * N; for(i = 0; i < N; i++){ arr[i] = sc.nextInt(); } s_x = arr[0]; s_y = arr[1]; s_z = arr[2]; for(i = 3; i < N ; i += 3){ sum += shortDist(arr[i], arr[i+1], arr[i+2]); } System.out.printf("%.2f", sum); } private static float shortDist(int x, int y, int z) { float dis; // check if the Zaxis and any other one axis are the same. if(z == s_z && (y == s_y  x == s_x ) && s_z != 0){ //check if the x axis of next coordinate is same if(x != s_x){ dis = (2 * PIE * (Math.abs(x  s_x))) / 6.0f; } //check if the y axis of next coordinate is same else{ dis = (2 * PIE * (Math.abs(y  s_y))) / 6.0f; } } else{ dis = (int)(Math.sqrt(Math.pow(x  s_x, 2) + Math.pow(y  s_y, 2)) + Math.abs(z  s_z)); } s_x = x; s_y = y; s_z = z; return dis; } }
import math PIE=3.14 def shortDist( x,y,z,sx,sy,sz): dis = 0.0 # if the x or y axis same as z axis if(z == s_z and (y == s_y or x==s_x) and s_z != 0): # if the x axis of next coordinate is same if(x != s_x): dis = (2 * PIE * (abs(x  s_x)))/6.0 # if the y axis of next coordinate is same else: dis = (2 * PIE * (abs(y s_y)))/6.0 # else means bee is going to another face #finding eculidean distance else: dis = int((math.sqrt(pow(xs_x, 2) + pow(ys_y, 2)) + abs(z  s_z))) s_x = x s_y = y s_z = z return dist,s_x,s_y,s_z n=int(input()) arr = [int(x) for x in input().split()] s_x = arr[0] s_y = arr[1] s_z = arr[2] ans=0 for j in range(3,3*n,3): x,s_x,s_y,s_z= shortDist(arr[j],arr[j+1],arr[j+2],s_x,s_y,s_z) ans += x print(round(ans,2))
Question 5 : Hamming Distance
Problem Statement : Given two integers, the task is to find the hamming distance between two integers. Hamming Distance between two integers is the number of bits that are different at the same position in both numbers.
Example :
Input 1:
a= 10 , b =8
Output 1:
1
Explanation: 10= 1010 , 8=1000 , No of different bits=1.
Input 2:
a=9, b=14
Output 2:
3
Explanation: 9=1001 , 14=1110 , No. of different bits=3.
import java.util.*; class Solution { public static int hammingDistance (int a, int b) { int max = a > b ? a : b; int count = 0; while (max > 0) { if ((a & 1) != (b & 1)) count++; a = a >> 1; b = b >> 1; max = max >> 1; } return count; } public static void main (String[]args) { Scanner sc = new Scanner (System.in); int a = sc.nextInt (); int b = sc.nextInt (); System.out.println (hammingDistance (a, b)); } }
#include<bits/stdc++.h> using namespace std; int hammingDistance (int a, int b) { int max = a > b ? a : b; int count = 0; while (max > 0) { if ((a & 1) != (b & 1)) count++; a = a >> 1; b = b >> 1; max = max >> 1; } return count; } int main () { int a, b; cin >> a >> b; cout << hammingDistance (a, b); return 0; }
FAQs on Thales Coding Questions
Question 1: In what field does Thales primarily work on?
Thales is a multinational technology company that operates in the aerospace, defense, transportation, and security sectors.
Question 2: Is coding questions asked in Thales Recruitment Process?
Yes, in both 1st Round (i.e Online Assessment) and 2nd Round (i.e. Technical Interview) coding questions was asked in Thales Recruitment Process.
Question 3: Does Thales offer internships in India?
Yes, Thales does offer internships in India for students and recent graduates. You can check the Thales careers page for current internship opportunities.
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment