Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Find the Direction CodeChef Solution

Problem – Find the Direction CodeChef Solution

This website is dedicated for CodeChef solution where we will publish right solution of all your favourite CodeChef problems along with detailed explanatory of different competitive programming concepts and languages.
<<Previous CodeChef Problem Next Codechef Problem>>

Find the Direction CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int x;
	    cin>>x;
	    if(x%4==0)
	    cout<<"north"<<endl;
	    else if(x%4==1)
	    cout<<"east"<<endl;
	    else if(x%4==2)
	    cout<<"south"<<endl;
	    else
	    cout<<"west"<<endl;
	}
	return 0;
}

Find the Direction CodeChef Solution in C++14

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t,x;
	cin>>t;
	while(t--){
	    cin>>x;
	    if(x%4==1)
	    cout<<"East"<<endl;
	    else if(x%4==2)
	    cout<<"South"<<endl;
	    else if(x%4==3)
	    cout<<"West"<<endl;
	    else
	    cout<<"North"<<endl;
	}
	return 0;
}

Find the Direction CodeChef Solution in PYTH 3

# cook your dish here
t=int(input())
for i in range(t):
    n=int(input())
    if n<=4:
        a=n
        if a==1:
            print("East")
        elif a==2:
            print("South")
        elif a==3:
            print("West")
        else:
            print("North")
    elif n>4:
        a=(n%4)
        if a==1:
            print("East")
        elif a==2:
            print("South")
        elif a==3:
            print("West")
        else:
            print("North")

Find the Direction CodeChef Solution in C

#include <stdio.h>

int main(void) {
	// your code goes here
	int t,x;
	scanf("%d",&t);
	for(;t>0;t--)
	{
	    scanf("%d",&x);
	    if(x%4==1)
	    printf("East\n");
	    else if(x%4==2)
	    printf("South\n");
	    else if(x%4==3)
	    printf("West\n");
	    else 
	    printf("North\n");
	}
	return 0;
}

Find the Direction 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
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int dir=0;
		int[] arr=new int[n];
		for(int i=0;i<n;i++)
		{
		    arr[i]=sc.nextInt();
		}
		
		for(int i=0;i<n;i++)
		{
		    dir=arr[i]%4;
		    if(dir==1)
		    {
		        System.out.println("East");
		    }
		    else if(dir==2)
		    {
		        System.out.println("South");
		    }
		    else if(dir==3)
		    {
		        System.out.println("West");
		    }
		    else
		    {
		        System.out.println("North");
		    }
		}
		
	}
}

Find the Direction CodeChef Solution in PYPY 3

t=int(input())
for i in range(t):
    x=int(input())
    if x%4==0:
        print("North")
    elif x%4==1:
        print("East")
    elif x%4==2:
        print("South")
    elif x%4==3:
        print("West")

Find the Direction CodeChef Solution in PYTH

# cook your code here
for i in range(int(input())):
    x=int(input())
    if x%4==0:
        print('North')
    elif x%4==1:
        print('East')
    elif x%4==2:
        print('South')
    else:
        print('West')

Find the Direction CodeChef Solution in C#

using System;

public class Test
{
	public static void Main()
	{
		// your code goes here
		int t = Convert.ToInt32(Console.ReadLine());
		
		for(int i = 0; i < t; i++)
		{
		    int x = Convert.ToInt32(Console.ReadLine());
		    
		    int m = x % 4;
		    string direction= String.Empty;
		    switch(m)
		    {
		        case 0:
		            direction = "North";
		            break;
		        case 1:
		            direction = "East";
		            break;
		        case 2:
		            direction = "South";
		            break;
		        case 3:
		            direction = "West";
		            break;
		    }
		    Console.WriteLine(direction);
		}
	}
}

Find the Direction CodeChef Solution in NODEJS

process.stdin.resume();
function runProgram(input){
 input=input.trim().split("\n");
 let t=+input[0]
 let line=1;
 for(let i=0;i<t;i++){
     let n=+input[line++]
     Check(n)
 }
}
function Check(n){
  let x=n%4
  console.log(x==1?"East": x==2? "South":x==3? "West":"North")
}

if (process.env.USER === "") {
  runProgram(``);
} else {
  process.stdin.resume();
  process.stdin.setEncoding("ascii");
  let read = "";
  process.stdin.on("data", function (input) {
    read += input;
  });
  process.stdin.on("end", function () {
    read = read.replace(/\n$/, "");
    read = read.replace(/\n$/, "");
    runProgram(read);
  });
  process.on("SIGINT", function () {
    read = read.replace(/\n$/, "");
    runProgram(read);
    process.exit(0);
  });
}


Find the Direction CodeChef Solution in GO

package main
import (
    "fmt"
    "bufio"
    "os"
)


func Reader(c chan int) {
    scanner := bufio.NewScanner(os.Stdin)

    for scanner.Scan() {
        line := scanner.Text()
        number := 0
        beg := false
        for i := 0; i < len(line); i++ {
            if '0' <= line[i] && line[i] <= '9' {
                beg = true
                number = number * 10 + int(line[i] - '0')
            } else {
                if beg == true {
                    c <- number
                }
                number = 0
                beg = false
            }
        }
        if beg == true {
            c <- number
        }
    }
}


func main(){
    w := bufio.NewWriter(os.Stdout)    
    defer w.Flush()

    inp := make(chan int, 4096)
	go Reader(inp)
	
	t := <-inp
	directions := []string {"North", "East", "South", "West"}
	for i := 0; i < t; i++ {
        x := <-inp
        fmt.Fprintln(w, directions[x % 4])
	}
}
Find the Direction CodeChef Solution Review:

In our experience, we suggest you solve this Find the Direction 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 Find the Direction CodeChef Solution.

Find on CodeChef

Conclusion:

I hope this Find the Direction 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!

More Coding Solutions >>

Cognitive Class Answer

CodeChef Solution

Microsoft Learn

Leave a Reply

Your email address will not be published. Required fields are marked *