+ 3
I tried this pig latin challange still failed two test cases what might be problem?
Pig Latin +50 XP You have two friends who are speaking Pig Latin to each other! Pig Latin is the same words in the same order except that you take the first letter of each word and put it on the end, then you add 'ay' to the end of that. ("road" = "oadray") Task Your task is to take a sentence in English and turn it into the same sentence in Pig Latin! Input Format A string of the sentence in English that you need to translate into Pig Latin. (no punctuation or capitalization) Output Format A string of the same sentence in Pig Latin. Sample Input "nevermind youve got them" Sample Output "evermindnay ouveyay otgay hemtay" https://code.sololearn.com/cr7eNP5csTCx/?ref=app
11 odpowiedzi
+ 6
That's my solution to it
sentence = str(input())
new_sentence = ""
for word in sentence.split():
new_word = word[1:] + word[0] + "ay "
new_sentence = new_sentence + new_word
print(new_sentence)
+ 3
This is what I have coded for this problem in C programming....This programming executed successfully....
Hope this would help u....
C programming
#include <stdio.h>
#include<string.h>
int main()
{
char a[100];
fgets(a,100,stdin);
int i=0,j=0,d=0,e=0;
while(a[i]!='\0')
{
for(j=0;j<=strlen(a);j++)
{
if(a[i]==a[j])
{
d++;
}
}
if(d>=2)
{
printf("Deja Vu");
e=1;
break;
}
d=0;
i++;
}
if(e==0)
{
printf("Unique \n");
}
return 0;
}
All the cases ran successfully....
https://www.sololearn.com/Profile/21558748/?ref=app
+ 2
+ 2
TASK;
Your task is to take a sentence in English and turn it into the same sentence in Pig Latin!
INPUT FORMAT ;
A string of the sentence in English that you need to translate into Pig Latin. (no punctuation or capitalisation)
OUTPUT FORMAT ;
A string of the same sentence in Pig Latin.
=====My Answer in java=====
import java.util.*;
import java.util.ArrayList.*;
public class Program{
public static void main(String[] arg){
Scanner ip=new Scanner(System.in);
String s=ip.nextLine();
char[] c=s.toCharArray();
ArrayList<String> arr= new ArrayList<>();
char f=c[0]; int m=1;
String name="";
for(int i=0;i<c.length;i++)
{if(c[i]==' '||i==c.length){
arr.add(name+f+"ay");
name=""; f=c[i+1]; m=i+2;
continue ; }
else if(m<=i)
name+=c[i];}
arr.add(name+f+"ay");
for(int i=0;i<arr.size();i++)
System.out.print(arr.get(i)+" "); }
}
+ 2
For c#
Its my solution
##########
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sololearn
{
class Program
{
static void Main(string[] args)
{
string finall="";
string sent=Console.ReadLine();
string [] words=sent.Split(' ');
foreach (string value in words)
{
finall+=value.Substring(1,value.Length-1)+value.Substring(0,1)+"ay ";
}
Console.WriteLine(finall);
}
}
}
+ 1
Ayush Dwivedi failed two test cases but different
+ 1
You passsd all test cases?
0
Using java# Solution:
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String txt = scan.nextLine();
char startChar = txt.charAt(0);
for(String i: txt.split(" ")){
System.out.print(i.substring(1)+i.charAt(0)+"ay"+" ");
}
}
}
0
sent = input().split()
for i in sent:
h = list(i)
h.append(h[0])
h.remove(h[0])
h.append("a")
h.append("y")
h = "".join(h)
if sent.index(i) < len(sent):
h = h + " "
sent[sent.index(i)] = h
sent = "".join(sent)
print(sent)
0
My solution with python
text =input().split()
for word in text:
word = "".join(word[1:]+ word [0]+ "ay")
print (word, end=" ")
- 1
For c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sololearn
{
class Program
{
static void Main(string[] args)
{
string finall="";
string sent=Console.ReadLine();
string [] words=sent.Split(' ');
foreach (string value in words)
{
finall+=value.Substring(1,value.Length-1)+value.Substring(0,1)+"ay ";
}
Console.WriteLine(finall);
}
}
}