One more solution: for 0 to 100: String s = "programmin"; int zero = s.length()-s.length(); int hundred = s.length() * s.length(); for(int i = zero; i
@sandipanmallick61413 жыл бұрын
You are my Guru.... 🙏🙏
@skb71983 жыл бұрын
I think this should also work ... modified now for(int i='e' -'d'; i
@satishkrshnn3 жыл бұрын
Khatarnaak. Pranaam guru
@jeyhunaliyev17653 жыл бұрын
including zero its awesome thanks a lot
@mislommislom92023 жыл бұрын
Switch to python it is easier: for i in range(ord(e)): print(i)
@luisacuna83153 жыл бұрын
I remember I got this question in one interview I had. My first thought was "Either this is a joke, or I'm not ready for this". Years later the solution seems so simple now. Very well done.
@taragnor3 жыл бұрын
Well honestly it's a stupid question. I mean, it's asking you to program things in a weird impractical obtuse way. It'd be sort of like going for your drivers test and the instructor having you turn the wheel with your feet and operate the pedals with a long stick. Maybe it might be a decent question for intro hacking stuff, but that's about it.
@naveenautomationlabs3 жыл бұрын
Ya it was just asked in one of the interviews and we gave multiple solutions here.
@luisacuna83153 жыл бұрын
@@taragnor agreed. Also when they give you complicated math Problems. Do you want me to code or become a physicist. Darling you can't have both
@munemshahariar25033 жыл бұрын
@@luisacuna8315 thats what i cant make them realize
@bolpol80853 жыл бұрын
@@taragnor It is a stupid question sure, But it also tests how well you know about programming and how computers work.
@pramodNavali3 жыл бұрын
I thought of ASCII value, but the first solution really awesome.
@sakandchoudhary29413 жыл бұрын
that's Exactly what I was thinking of 😂
@katyayini84453 жыл бұрын
Me too..
@lupsik13 жыл бұрын
Right on, first thought was ASCII value and then just ++ it edit : wait the solution in the video is exactly that lmao
@sholland423 жыл бұрын
Agreed, I thought ASCII too.
@William_Clinton_Muguai3 жыл бұрын
Exactly what I was thinking of.
@vladosononame63763 жыл бұрын
When you want secure your code from understanding of classmates
@sumitgoyal385 Жыл бұрын
@@programaths itta serious nai hona bhai life me he just made joke
@devninja3 жыл бұрын
nice , but you used a number in 's1', just joking.
@naveenautomationlabs3 жыл бұрын
Hahaha that's a good catch 😭😭😭
@nihalnaughty9113 жыл бұрын
@@naveenautomationlabs yeah🤣
@yaswanthyv38373 жыл бұрын
Yeah really..
@Ammarkoka3 жыл бұрын
@@naveenautomationlabs yeah variable declaration s1 itni bhi kya zarurat padh gyi S k saath 1 lene ki 😂
@naveenautomationlabs3 жыл бұрын
@@Ammarkoka :)
@mukeshsiyak56233 жыл бұрын
Which company asks such questions. Companies i've encountered starts interview like "you are given a tree ......."
@sourabhchoudhary72893 жыл бұрын
😂
@azhagurajaallinall1263 жыл бұрын
And tell us more about your interview 😁 It may help others to prepare for their interviews
@kartikjoshi4283 жыл бұрын
Lol true yrr..
@dailyinterestingshorts29643 жыл бұрын
Le me: i will plant it
@azhagurajaallinall1263 жыл бұрын
@@dailyinterestingshorts2964 you mean planting a "tree" don't we just cut it down,because of its size
@Moonz973 жыл бұрын
My solution is braindead I suppose lol. int zero = "".length(); int one = ".".length(); int hundred = Integer.valueOf(Integer.toString(one) + Integer.toString(zero) + Integer.toString(zero)); for(int i = one; i
@AndreasDelleske3 жыл бұрын
Zero is still an int. Int is a number.
@Moonz973 жыл бұрын
@@AndreasDelleske The way I understood the problem was to not use any number literals, i.e. 0-9 rather than not using any numeric types.
@otesunki3 жыл бұрын
@@AndreasDelleske dude the for loop in the video LITERALLY USES AN INT int one = 'A'/'A';
@monochromeart73113 жыл бұрын
@@AndreasDelleske also chars are numbers of 1 or 2 bytes, and the problem was not using any number literals.
@doomse1503 жыл бұрын
@@AndreasDelleske The question was about number literals (the so called magic numbers when talking about code-style) and not numerical datatypes
@TheGermanRoxie3 жыл бұрын
Seems Naveen Automation Labs is the best thing ever Happened to QA Engineers.
@sharadsharma31763 жыл бұрын
I'm thinking of doing it with fork(). Remember it returns pid as 1, we can add bunch of forks to achieve our result.
@naveenautomationlabs3 жыл бұрын
sounds interesting.
@ankgaur3 жыл бұрын
How fork()
@StefanReich3 жыл бұрын
@@tripplefives1402 That's so dirty and so clean at the same time
@bluediamond23093 жыл бұрын
@@tripplefives1402 And what are we going to do with a ZerO ?
@SameerKumar-yu1xi3 жыл бұрын
I also thought for this approach but was not exactly confident abt the exact ASCII value... But ye that is the appropriate that came into my mind when I saw scenario🖐️
@aniketsonawane91883 жыл бұрын
Awesome 🔥
@FurquimRafa3 жыл бұрын
First thing that came to my mind for python was: Print(len("a")) Print(len("aa")) Print(len("aaa")) Print(len("aaaa")) ... And so on 😅
@naveenautomationlabs3 жыл бұрын
😂
@hotmole76213 жыл бұрын
Lol, but it works
@Nikolapestanac3 жыл бұрын
Recursion for that is funnier since you just put an if with 100 a
@bubbleteaichooseyou3 жыл бұрын
That's technically correct
@arnavrawat98643 жыл бұрын
@@Nikolapestanac you can push 'a' into an array each time Have it print the length of an array This is really cool, but a stop mechanism is needed
@kivuosark20883 жыл бұрын
This question should instantly click the concept that characters are stored as ASCII values. Pretty easy question.
@aflaqueahmad3003 жыл бұрын
It clicked but i dont remember the values lol
@sarthaksrthkyoutu1003 жыл бұрын
The question is of logic not memory
@excaliburofgachagames92413 жыл бұрын
There is a question from my class I'd love to take a picture of. The students think that it is hard, I didnt even think to do that, like ever. I learned more from you than that said class btw.
@naveenautomationlabs3 жыл бұрын
Glad that you liked it :)
@bettercallbo3 жыл бұрын
You could also use the args array And give the numbers as input at start. The rule only says that the numbers are not allowed in code
@max_2083 жыл бұрын
You would still have to retrieve the data from the args array.
@bettercallbo3 жыл бұрын
@@max_208 yes but the numbers wouldn't be hardcoded The wording sounded to me that this was the rule
@tushar007kr3 жыл бұрын
Awesome 😊👍 Ok one more possible solution for this... Static int i;//default 0 i++;// i=1 And later we can follow with ascii for setting limit 😊
@hassaanraheem56443 жыл бұрын
Python Code : a = int(True) b = int(False) f_range = int(str(a) + str(b) + str(a)) for i in range(a,f_range): print(i)
@gerryiobbi90253 жыл бұрын
wow, could you explain me please? I'm just a beginner in python!
@hamzapatel033 жыл бұрын
@@gerryiobbi9025 a = int(True) returns integer 1 b = int(False) returns integer 0 f_range = int(str(a) + str(b) + str(a)) returns integer 101 Since you're a beginner, let me break it down for you str(a) returns "1" str(b) returns "0" str(a) returns "1" Now, if you concatenate these strings, you'd get a string which would be "101" because "1" + "0" + "1" returns "101" Now, all you need to do is type cast(convert the data type from one to another) this value i.e. int(str(a) + str(b) + str(a)) means int("101") which returns integer 101 Now, you can use a for loop to iterate through the values, for that he used the function range which essentially accepts two arguments, first is the starting integer which is a in our case, i.e. 1 and second is the ending integer which is f_range in our case, i.e. 101 Note: The ending integer is exclusive, meaning it won't be considered in the iteration i.e. our loop will iterate from 1 to 100 I'm assuming you'd know what print(i) does
@gerryiobbi90253 жыл бұрын
@@hamzapatel03 Thank you so much!!! I really appreciated your explanation and I understood clearly :)
@samudraganguly67113 жыл бұрын
Nice one buddy
@sarthaksrthkyoutu1003 жыл бұрын
@@gerryiobbi9025 # Online Python compiler a =(True+True+True+True+True+True+True+True+True+True) a =a*a for i in range(True,a+True): print(i)
@akhileshhalkarni81923 жыл бұрын
My solution : import java.math.BigInteger; public class ClassName{ public static void main(String[] args) { BigInteger s = BigInteger.ONE; int d = 'd'; int i = s.intValue(); while(i
@souvikchatterjee74003 жыл бұрын
Hey Naveen, this was a tricky but simple program and your solution was awesome. I faced similar situations where, I was asked to write a program and on that spot I wasn't able to give the proper solution. However after coming out of the interview, I thought about it for some time and I got a quick solution for it later. This happened to me couple of times. Could you please provide any suggestions how we can practice so that in such scenarios we can provide the solution quickly?
@sherlockholmes80963 жыл бұрын
As an alternative for "one" you could declare variable as the static variable which would initialize it to 0 then increment it once before using inside the loop
@karthiiekeyan3 жыл бұрын
using ASCII in python: for i in range( int(ord('a')/ord('a')), ord('d') ): print(i)
@thoperSought3 жыл бұрын
awesome, was looking for this. wouldn't you want ord('e'), tho?
@rohittester46693 жыл бұрын
we can do by it also ,for get max ,you can take any string for getting 100 String s="abc",s1="bcde",s2="jhkgj"; int min=s1.length()-s.length(); int max=s1.length()*s2.length()*s2.length(); for(int i=min;i
@VIK2000GEV3 жыл бұрын
in C, I would solve it like this: #include int zero = ('a' == 'b'); int one = ('a' == 'a'); int sixty_four = sizeof(uint64_t) * sizeof(uint64_t); int thirty_two = sixty_four>>one; int four = sizeof(uint32_t); int hundred = sixty_four + thirty_two + four; // Rest is obvious
@vihaanfunandcrafts98513 жыл бұрын
If you don't remember the ASCII values you can also use the diff (var - 'a'). This will give values 1 to 10 if var goes from b to k.
@Lhorez3 жыл бұрын
Another approach would be to take the ascii value of 'a' divided by itself for 1 and the ascii value of 'a' minus itself for 0. Then the rest can work itself out.
@shivajidandge66513 жыл бұрын
We can also do like this for(char c = 'A'%'A';c < 'd'; c++) { System.out.println(c+1); }
@abrar__jamadar3 жыл бұрын
I got this as a recommendation and now am subscribed to your channel.
@LocherYT3 жыл бұрын
I googled for this because my buddy told me that came up in his interview for maintaining a starbucks logistic system. I originally thought this was an exercise for smartasses who memorized the entire ASCII table for fun but the first solution really proves how a programmer can and should be able to exert a certain amount of abstract thinking to get what he wants.
@bettyswunghole33103 жыл бұрын
Interesting...I would have done it using ASCII values (but only because I've been looking at a bit of Assembler recently, and the idea of manipulating ASCII values to perform calculations is fresh in my mind!). Whether I would have been able to do it under under pressure in a job interview is an entirely different matter, however!
@Gaurav_Khurana3 жыл бұрын
Good one... Very difficult to crack durong interview if the divide concept you dont know... I knew the ASCII part but did not knew.. Division of characters is possible
@naveenautomationlabs3 жыл бұрын
yes we can perform any arithmetic operations on characters : System.out.println('a' * 'b'); //9506 System.out.println('a' + 'b'); //195 System.out.println('a' - 'b'); //-1 System.out.println('a' / 'b'); //0
@k.ravichandra10492 жыл бұрын
Thanks Naveen bro for covering this program.
@inigo87403 жыл бұрын
I don't know if this is possible in Java, but in Python you can do int(True) to get 1, and the rest is easy.
@Techfly113 жыл бұрын
Using True was my first thought as well.
@PoojaThakur-bp2tz3 жыл бұрын
This type of content is the reason you are the best guide for us🙏 What a video , it reminds me to brush up my ASCII knowledge 😁 Started practicing already 😁
@camelcasedsnivy3 жыл бұрын
There is even a way to do it without having integers in your code, without 100 prints. Just have an array of chars that represent every 1 digit number as a char. Then have a for loop and a nested for loop so that you could print i + j (if those are your variables)
@cedric17313 жыл бұрын
I am not sure right now if this is also the case in Java but in C(++) true=1 and false=0. This means you could do something like: int i = (int) true + (int) true; i *= i; //4 i *= (i+(int) true)*(i+(int) true); //100 And then you do a normal for loop.
@gtg238s3 жыл бұрын
This can be done with Neo4J graph database where the nodes are numbers “one”, “two”, etc.. then write a query to retrieve and print the nodes in sequence
@conman6983 жыл бұрын
Technically, this is impossible as everything gets turned into binary which means that you are using numeric values regardless of what you program.
@joseville3 жыл бұрын
@Apple TV Define "the code"? The code is written in ascii which are numbers lol. The whole question is just ill defined and op makes a good point. It's not "obvious" at all. Total ambiguity. Besides, you're supposed to ask clarifying questions in an interview and this would be a good one.
@gohanvippi3 жыл бұрын
Hi Naveen, one more way of printing came to my mind by manipulating default initialized value of class variable : public class NaveenJavaQuestion { static int a; public static void main(String[] args) { a++; int b = a; int c = (b+b+b+b); String s = Integer.toBinaryString(c); int d = Integer.parseInt(s); for(int i = b ; i
@c00Lify3 жыл бұрын
package main import ( "fmt" ) func main() { var x int x++ one := x two := one + one four := (two * two) five := four + one hundred := five * five * four for i := one; i
@Gruggo3 жыл бұрын
After seeing this video title, I decided to have a go before Watching. Having still not watched, C# makes this quite easy imo. Idk if this is in the spirit of the question though. char start = Char.MinValue; while (start < 'd') { start++; Console.WriteLine((int)start); }
@naveenautomationlabs3 жыл бұрын
good one, you made it very easy.
@Gruggo3 жыл бұрын
After watching, string lengths is a neat idea. I like that.
@mahalakshmikrishnadoss22723 жыл бұрын
Ascii was my idea too... but 1st solution u r amazing naveen... 👏
@lizard4503 жыл бұрын
Neat idea ... If someone asked me this in an interview I think I'd stop the interview.
@pakashvalarthasan81663 жыл бұрын
I used to watch your videos without subscribe but after watching this I tapped on subscribe button
@akshaysapkale91363 жыл бұрын
This goes same for me, I subscribed him !
@CerikNguyen3 жыл бұрын
One solution that doesnt use string is to initialize a variable a, then set the value of a = (int)&a. Since any address of a given that the program runs is not 0, you now have a non-zero variable. Divide a by itself and you got yourself a = 1, get b = 100 by whichever means you want using a and you have a solution without using strings. Note that by having an uinitialized variable also makes it non-zero sometimes, but obviously this doesnt work all the time.
@juanjose60913 жыл бұрын
I tried to solve it before watching the video. I thought we weren´t allowed to use int values, thus i came up with this solution: public class print{ public static void main(String args[]){ char let1 = 'a'; char let2 = 'a'; char let3 = 'e'; boolean freno = false; while(!freno){ System.out.println(let2 - let1); let2++; if( let2 - let1 == let3){ freno = true; } } } } I had to use the ASCII table for this. I believe that would be forbidden in an interview. However, if I come across this question in a real job interview, I will know how to solve it. Thank you so much :).
@aelithmackinnon86563 жыл бұрын
This is easy. Is_string("a string"), take the result of the function call and put it in a variable. Var++ and output var++ each loop. Stop the loop with a function call to size_of_string(typecastasstring(var)) when it is == size_of_string("abc"). Done.
@puneri7433 жыл бұрын
Whoever asks such questions in the interview must be able to explain where and why he has to use such code. I always prefer to ask and to be asked the valid technical and logical questions and problems faced in our daily work. e.g. collections, design patterns, clean code, custom exception handling and so on.
@stormerthe2nd3 жыл бұрын
Yeah lol i mean what could be the worst case where numbers wouldn't be allowed in a code
@MinecraftTestSquad3 жыл бұрын
So before watching, and seeing it’s in Java... Primitive int values in Java default to 0, and the letter ‘d’ is ascii 100, sooo int start; int end = (int) ‘d’; do { start++; System.out.println(start); } while(start < end);
@Annihilated4813 жыл бұрын
You're forgetting if this is in a function, "start" has to be initialized
@deveshnagawat14543 жыл бұрын
With the basic knowledge of Python I did it using True and False value ie 1 & 0 and concatenated it str -> int then applied for loop with the range of True+False+True.
@chinmaynaik39623 жыл бұрын
I am not good at Java syntax so here is one from me in python: for i in range(len("..........")**len("..")): print(i+len('.')) (** = Power)
@apmcd473 жыл бұрын
I thought C and bitwise shift: int main(int argc, char **argv) { int acc, count; acc = ++count; // 1 acc
@TechLifeLabWorld3 жыл бұрын
If you use some data structure, just initialize the structure, print the length and then, append whatever to the data structure and repeat, until length(string(data_structure.length))==length("ABC")
@gameglitcher3 жыл бұрын
This is definitely a question to prompt questions based on how ambiguous it is. They are all literals so they are not actual numbers. It will need casting for the display lines, left the quote conversion out for readability. To abstract the digits out you would have to add a numeric operation of some sort. Now I ask if a string literal of digits is the same as a number, if they reply yes I don't want to work there anyways. for (char tens : " 123456789".toCharArray()) { if (tens != ' ') System.out.println(tens+'0'); for (char ones : "123456789".toCharArray()) { System.out.println(tens+ones); } } System.out.println("100"); I believe by using an integer variable and calculations you are violating the sanctity of the problem. You didn't "output the numbers 1 to 100 without using any numbers in your code" You indirectly assigned a number without using it's digits and proceeded to use that number to iterate and print the numbers from 1 to 100.
@Ellenki_0073 жыл бұрын
I am in love with for loop it's just cool.
@haileyen3533 жыл бұрын
(Written before watching video) With my limited apcsp knowledge... make a list, utilize appending items and list.length. probably gotta figure out how to loop it without numbers, but if all else fails, make it a function and copy/paste the function to cover 100 lines.
@dondigidon16333 жыл бұрын
Naveen, it's great! Thank you 🎉🎉🎉
@DanijelTurina9733 жыл бұрын
Since the terms of the task don't require the output to be *only* numbers 1 to 100, my solution in c is: #include #include int main() { int l = true; while(l) { printf("%i ",l); l++; } return 0; } Limiting it to 100 would require some fiddling.
@wristdisabledwriter28933 жыл бұрын
A different approach that is similar to the first is instead of int one make it string s1=“*” and instead of I=one use I=s1.length and change the original s1 to s2
@stellarfirefly3 жыл бұрын
My first thought was that even the output should have no decimal digits in it, and thus would output the words, "one", "two", "three", etc. all the way up to "one hundred". So I came up with a solution that did this, which was of course much longer than the 2-3 line solutions in this video, but I feel was more practical. :)
@Annihilated4813 жыл бұрын
A much simpler way is to make a while loop and check to see if the number as a string has a length of less than 3. int one = 'a' - 'a'; while (Integer.toString(one++).length() < "abc".length()) { System.out.println(one); }
@Ricocossa13 жыл бұрын
I've tried it in C++ before watching the video. The way I did it is I got a zero by Xoring a variable with itself, which I'm pretty sure is what the interviewers wanted the guy to do. I cheated a little bit for 100. I don't know a lot about ascii, but I know ' ' is 10. So I cast it to an integer and multiplied it by itself.
@vikrantambekar33943 жыл бұрын
Naveen thanks a lot Because of your Selenium Videos I got a Job in this pandemic situation I got Test Engineer profile Thanks a lot Naveen❤️❤️❤️
@welltypedwitch3 жыл бұрын
What a fun challenge. Here is my initial solution for haskell: one :: Int one = suc (getSum mempty) hundred = fromEnum 'd' main = traverse_ print [one..hundred] If you inline the definitions, you actually get a oneliner main = traverse_ print [suc (getSum mempty)..fromEnum 'd']
@Powerracer2513 жыл бұрын
This question is kind of stupid. Considering that you still need to use integers to accomplish the task in some way, I'd be a smart ass and just recast a boolean as an integer and use ++. I technically am not using numbers there.
@AmulBhatia853 жыл бұрын
You put number of strings in array and take its length in to a variable and do increment on the variable by ++, Ot will solve your problem.. enjoy
@naveenautomationlabs3 жыл бұрын
Can try with static int i (default value is 0): package JavaSessions; public class PrintOneToHundred { static int i; public static void main(String[] args) { /** * Output numbers from 1...100 * without using any numbers in your code. */ String s1 = ".........."; //10 dots i++; while(i
@Ellenki_0073 жыл бұрын
what's static here?
@vasanthanchinnasamy3 жыл бұрын
@@Ellenki_007 int i is static
@general.aladeeen8 ай бұрын
This is so good. Thanks man!
@divyavishwakarma20023 жыл бұрын
We can also use the concept of static variables as they get initialized with 0. And use them inside a recursive function which would check whether the number is less than the ASCII value of 'd'
@thegreatbambino33583 жыл бұрын
Double for loop with ascii chars. A-Z and A-D. Print outer timed (Z-A) + inner minus A
@R.B.3 жыл бұрын
You missed the obvious solution, Lambda Calculus. This was the best time to use Church Numbers if I've ever seen one.
@welltypedwitch3 жыл бұрын
But how are you going to print them without using digits in your string literals? :)
@R.B.3 жыл бұрын
@@welltypedwitch Church Numbers don't use a string literal... At a basic level it is just counting. Zero() is usually null or false, true is One(), Two() is One() add One(), or true add true. Three is One() add One() add One(), etc. At some point you have a Church Number representation of a ascii code equivalent you can use for display purposes. Once you have the ascii code for AsciiZero(), then you can use Zero() add One() to be able to print "1". It's not like this would be less code, but it would be in some perspectives, pure.
@welltypedwitch3 жыл бұрын
@@R.B. I know what church numbers are, but if you want to print them out you will still have to convert them to ascii somehow which really undermines the point of using church numerals in the first place (unless your language has a successor function for chars maybe, although that would still be a lot of work)
@R.B.3 жыл бұрын
@@welltypedwitch point taken. My approach would be using advantage of the environment the program is running on once I utilized some side effect like printing to the screen. In theory you could go all the way, but arguably you'd have to leave the realm of LC you really satisfy the problem statement.
@ragavaanvesh3 жыл бұрын
We can use big decimal constants.. for( BigDecimal i = BigDecimal.ONE ; i
@naveenautomationlabs3 жыл бұрын
Yeah good one
@allysondossantossilva68753 жыл бұрын
What I used in JavaScript was pretty much your first solution, except that I didn't made an division but an .indexOf() to create the "1"
@pa87313 жыл бұрын
In Python 3: one = int(True) zero = int(False) Hundred = int(str(one)+str(zero)+str(zero)) for each in range(one, Hundred+one): print(each)
@shankumondal28813 жыл бұрын
Ha ha ha .....😂 What a brilliant question . !!!! This is gonna my question when I am going to take any interview for our organization! 😁
@elikmtl9 ай бұрын
Thank you! You are the best!
@tarunmnair3 жыл бұрын
Nice video. i've given this answer, before :- for(int i = ('b'-'a'); i
@gezamolnar58143 жыл бұрын
I like your solution a lot! Elegant and does beat around the bush. :) If you took advantage of operator precedence, one statement loop body and changed the loop variable right after printing it, you'd end up with something like this: for(int i = 'b'-'a'; i
@wattsonthetube3 жыл бұрын
Any points for actually printing the string "numbers from 1 to 100 without using any numbers in your code" - I mean I followed the instructions, because it's a string not a number and gave you the output you asked for. Other than that I maybe would have used a char '1' with a StringBuilder in a while loop and concatenated the characters together - but if it was without numbers (not data types) entirely I would have froze. Thanks for reminding me that you can use chars as ASCII, and can perform mathematical operations on them.
@simonmultiverse63493 жыл бұрын
This is Python, where range(100) gives a list which starts at 0 and ends at 99. That's why I have to add two. two=len("a") ten=len("abcdeabcde") for five in range(ten*ten): print five+two
@phil29643 жыл бұрын
Amazing👍 hello from Russia🇷🇺
@herbert15573 жыл бұрын
I use python to Solve it's easier just use the ord() function wich decode strings to ASCII representation wich are integers and then just define a one as ord("d")-ord("e"). Where d and e on ASCII are 100 and 101 respectively finally just make a simple for loop: Code: one = ord("e")-ord("d") Hundred = ord("e") for num in range(one,Hundred): print(num)
@manavsaxena57363 жыл бұрын
Woah !!!! It was so easy yet brain teasing for a first year student . How can I develop this sort of logical skills in programming ? I am in first year .
@Beatleman913 жыл бұрын
If a company gives me a task like that on the interview I'd stand up and walk out. When you hire a doctor do you ask him, if he can cook a human liver? No? So why you ask a programmer to perform something he'll never actually do on the job?
@spiritwolf4483 жыл бұрын
Simple solution in C: #include int main(void) { int x = 'a'-'a'; while (++x
@darlyson52353 жыл бұрын
Nice video man, my solution was in python: for c in range ("aaaaaaaaaa".count ("a") * "aaaaaaaaaa".count ("a") + "a".count ("a")): if c > "a".count ("b"): print (c)
@naveenautomationlabs3 жыл бұрын
Thanks for sharing!
@gerryiobbi90253 жыл бұрын
Hi, I'm just a beginner in python. Could you explain me why you used an if statement here please? Thank you.
@darlyson52353 жыл бұрын
@@gerryiobbi9025 Hello Gerry, it's because the loop structure "for" begins from 0 (Zero), and the question requires from 1 to 100, the "if" statement tell to the computer to print the variable "c" only when variable "c" is bigger than 0, consequently the computer will print from 1 to 100.
@darlyson52353 жыл бұрын
"a".count ("b") will result in 0, because there's no "b" in "a"...
@gerryiobbi90253 жыл бұрын
@@darlyson5235 Thank you so much for the explanation!!! :)
@rajanisuphari3 жыл бұрын
We can create a 100 char string, read char by char, append the char to a diff string and print the len of growing string, avoiding using int in code
@RezekYT3 жыл бұрын
My solution in python: for i in range(ord('e')): print(i)
@condesamel3 жыл бұрын
That will start printing 0, won't it?
@RezekYT3 жыл бұрын
@@condesamel yeah, if you want to start with 1 you can change the range function with range(len('a'), ord('e')) for example
@calebfuller47133 жыл бұрын
Python FTW: for i in range(int(not ''),ord('e')): print(i)
@thoperSought3 жыл бұрын
nice int(True) seems simpler, tho?
@calebfuller47133 жыл бұрын
@@thoperSought True. Good one. I think my habit of using not came from code golfing in other languages where !a (or some undefined variable) would give 1, but yours is better in Python. ALTHOUGH... I realize now it can be a one-liner: print(*range(True,ord('e')),sep=' ') Let's see if someone can beat that! 😜
@thoperSought3 жыл бұрын
@@calebfuller4713 that's excellent, I love that. I always forget about sep
@rahul54813 жыл бұрын
Thank for this video...What kind of data structure questions we can expect in interview in term of programming..can u please suggest
@sourestcake3 жыл бұрын
Here's my solution in C. Made it before looking at comments, so i did zero-initialization with static. I could've just used XOR on a local variable. Also this only works with ASCII, since it relies on 'd' having a decimal code of 100. You could also count up to that by using sizeof on an array, or doing stuff in Brainfuck-like increments. #include static int i; int main(int argc, char **argv) { for(++i; i
@iGalYaiR3 жыл бұрын
I thought you a solution using boolean values as binary values. Start from 1 (true) and go on by adding 1 (true) and shifting left until 100 is achieved (this can be done by saving 100 beforehand in a variable using bits)
@iGalYaiR3 жыл бұрын
@Apple TV Actually i thought of implementing it in python. After a quick google search it seems like there are bit manipulations operators in java.
@groverongo2433 жыл бұрын
Before watching the video: #include int x; int main(){ char c{'c'}; while(x!=c) std::cout
@sherwinvaz3 жыл бұрын
At first I was also confused how do I solve it then when he started coding I kinda got a clue and had a rough idea to progress using ascii. Pretty Impressive I hadn't come across such question nor did I know I could use out of box solution like this
@ivan8or3 жыл бұрын
i came up with: int a = Integer.MAX_VALUE - Integer.MAX_VALUE; while( (a+"").length() < 3){ System.out.println(++a); } using the ASCII table is pretty smart though :')
@naveenautomationlabs3 жыл бұрын
Good one but you are using number 3 in your code.
@sayantandhara90993 жыл бұрын
We can type cast a boolean true into an integer which gives 1. This will be used for one
@anthonyjedi69983 жыл бұрын
My first thought was KBReader and work off of that because they never said that you couldn’t input numbers plus it could be seen as being able to apply to more things
@ScorpioHR3 жыл бұрын
javascript version (it works): New version - more obfuscated: var _dot="."; function dash(dot) { let type = typeof dot; dot +=""; if(type === "number") console.log(dot); else dot = dot.length return dot; } function not(dot) {return dash(dash(dash(dot))) < dash("dot") ? not(dot+=_dot) : dot; } not(_dot);
@SidTheBot3 жыл бұрын
Mylogic in Python: little messy print(*list(range(int(True),int(str(int(True)) + str(int(False)) + str(int(True))))))
@lekdo12853 жыл бұрын
Python: text1 = "p" one = len(p) text2 = "pppppppppp" ten = len(text2) for x in range(one, ten * ten + one): print(x)
@ritikajaiswal5343 жыл бұрын
Very nice and smooth way of doing this.. thanks!!
@mrswe40623 жыл бұрын
Create an enum with: zero, one and, two. Start for loop at index of one and end it when log(i) = index of two
@saintcorvic11943 жыл бұрын
This man is a genius. The first implementation is almost just as simple as using numbers.
@daniilorekhov91913 жыл бұрын
My initial thought was doing something like int(True) to get a 1 and then use it to get 100 (1+1=2, 2*2*2=8, 2+8=10, 10*10=100)
@daniilorekhov91913 жыл бұрын
Also, can use shifting bits after doing int(True) to get 2 and 8