+ 5
YouTube Link Finder
YouTube Link Finder please provide a link to the general rules for translating the path to the video into a short link (дайте, пожалуйста, ссылку на общие правила перевода пути к видео youtube в короткую ссылку)
33 Answers
+ 7
Walter Alleyz
I ask "what is short link for youtube". Not "how do it":)
+ 7
print(input()[-11:])
🤔🤔🤔
+ 6
🌟(Pro)metheus 🇸🇬
Thank you, but I do not need a ready-made solution. I do not know the principle of translation. As if I were doing this with my hands in the address bar
+ 4
🌟(Pro)metheus 🇸🇬
Why https://www.youtube.com/watch?v=RRW2aUSw5vU
Output:
RWW2aUSwvU
Why not RRW2aUSw5vU?
+ 4
I did:
str = str.split('/')
str = str[-1:]
hasEqual = str.find('=')
print(str if hasEqual != -1 else ...)
+ 3
In this code coach description of example is wrong, because for https://www.youtube.com/watch?v=RRW2aUSw5vU
answer must be RRW2aUSw5vU.
But author write:
Sample out is RRW2aUSwvU
You lost number 5
+ 3
Here is my simple python code..
s=input()
if "com" in s:
print(s[32:])
else:
print(s[17:])
+ 3
Petr
One Important fact is that GENERALLY, last 11 letters of link is the youtube ID !!!
+ 3
Using C:
#include <stdio.h>
int main() {
char a[100];
char f[12];
int l = 0, i, j = 0;
scanf("%s", a);
for(i = 0; a[i] != '\0'; i++) {
l++;
}
for(i = l; i > l - 12; i--) {
f[j] = a[i];
j++;
}
for(i = 11; i > 0; i--) {
printf("%c", f[i]);
}
return 0;
}
+ 2
You know there are 2 possible youtube link stuff in front of the code.
Use str.replace()
+ 2
It is supposed to RRW....
+ 2
The format of the string can be in "https://www.youtube.com/watch?v=kbxkq_w51PM" or the shortened "https://youtu.be/KMBBjzp5hdc" format.
Note how "https://www.youtube.com/watch?v=" and "https://youtu.be/" are unnecessary additions that should be removed.
+ 2
Hello friends I try this!
str=input()
if 0<len(str)<32:
for i in range(17,len(str)):
print(str[i],end="")
else:
for i in range(32,len(str)):
print(str[i],end="")
+ 2
Here is my simple python code
s=input()
if "com" in s:
print(s[32:])
else:
print(s[17:])
+ 2
//solution in java
import java.util.*;
public class Program {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
String k=in.next();
if(k.lastIndexOf("=")!=-1)
System.out.println(k.substring(k.lastIndexOf("=")+1));
else
System.out.println(k.substring(k.lastIndexOf("/")+1));
}
}
+ 2
#include <iostream>
#include <string>
using namespace std;
//ADD SWITCH CASE AND GET INPUT FROM USER ARE THE CHANGES NEEDED
int main()
{
string video_link= "https://www.youtube.com/watch?v=kbxkq_w51PM";
int size=video_link.length();
string video_id="";
for(int i=0;i<100;i++)
{
if(video_link[i]==video_link[30])
{
i=i+2;
for(int j=i;j<size;j++)
{
video_id=video_id+video_link[j];
}
cout<<video_id<<endl;
}
}
//_______//
string video_link1="https://youtu.be/KMBBjzp5hdc";
int size1=video_link1.length();
string video_id1="";
for(int i=0;i<100;i++)
{
if(video_link1[i]==video_link1[13])
{
i=i+4;
for(int j=i;j<size1;j++)
{
video_id1=video_id1+video_link1[j];
}
cout<<video_id1;
}
}
}
+ 1
Hey, guys. My .C code failed in every test case but it's output look just like expected output. Can someone help..
https://www.sololearn.com/Discuss/2183481/?ref=app
#include <stdio.h>
int main() {
char a[42]={0};
int c=32,b=17;
for(int I=0;I<=42;I++){
scanf("%c",&a[I]);
}
if(a[31]!=0){
for(int i=0;i<=11;i++){
printf("%c",a[c]);
c++;
}
}if(a[31]==0){
for(int j=0;j<=11;j++){
printf("%c",a[b]);
b++;
}
}
return 0;
}
+ 1
you can solve it by using only the basics of python ✌
https://code.sololearn.com/cg5Oo2XOAt6K/?ref=app
+ 1
My python code :
x=input()
l=len(x)
a=x.index("/")
if "=" in x:
s=x.index("=")
print("",x[s+1:l])
if "=" not in x:
s1=x.index("/")
if "/" in x[s1+3:l]:
s2=x[s1+4:l].index("/")
sf=s1+s2
print("",x[sf+5:l])
+ 1
Just wondering out aloud... What is the logic behind setting this question as medium difficulty in Code Coach🧐😗?
The solution is effectively an one-liner and someone with basic knowledge of list slicing could do it. 🙄