This is a repository containing the solutions for the tasks given out by Gurzu Inc. as part of their recruitment process.
Q. There are 50 dice. 20 of them are facing 4. Remaining 30 are facing 3. You can’t see which dice is facing what number. Write pseudo code to separate these 50 dice into 2 groups, so that both groups have the same number of 4’s.
There are total 50 dice with 20 of them facing 4 and 30 facing 3. Therefore, to divide the 50 dice into 2 groups such that each group has equal no. of dice facing 4, both the groups must have 10 dice facing 4. Below is the step by step pseudo code for the process:
array1=[50 dices]
array2=array1.splice(0,array1.length)
count
occurence of dice facing 4 inarray1
if count==10
thenreturn array1,array2
else if count<10
then,loop
througharray2
, andif current_element==10
remove and add toarray1
and repeat untilcount==10
else if count>10
then,loop
througharray1
, andif current_element==10
remove and add toarray2
and repeat untilcount==10
Q. A comma separated file(csv) has 5 columns and 10 rows. Write shell commands to extract the value of 3rd column 5th row and output the result into a text file.
In the above group of piped shell commands (UNIX), the 1st command cat
outputs the contents of the file1.csv
file, the 2nd command sed
extracts the 5th line/row of the output, the 3rd command cut
extracts the 3rd value of that row and the lastly the 4th command cat>
stores the result into file2.csv
.
A React Native Weather App for viewing weather forecast for the whole week for any city. The app fetches the data from the Open Weather API. Download APK file.