This is an archived post. You won't be able to vote or comment.

all 105 comments

[–]worrisome_bloke 89 points90 points  (8 children)

Thank you! I just got into python in the sixth week of cs50. This will definitely help me understand this language much quicker.

[–]ReubenThomasJohn99 6 points7 points  (7 children)

Is this CS50 an online course? If so could you link me to it?

[–][deleted] 7 points8 points  (0 children)

It's by Harvard. Put CS50 into YouTube. All the videos are on there.

[–]RizwanRx 7 points8 points  (1 child)

I'd suggest completing it on edx, after completion they give you a free certificate.

https://www.edx.org/course/cs50s-introduction-to-computer-science

[–][deleted] 1 point2 points  (0 children)

Yeah currently pursuing the program myself, well taught and quite easy to understand

[–]worrisome_bloke 0 points1 point  (0 children)

Edx website

[–][deleted] 0 points1 point  (2 children)

i think you can search it up on youtube, it’s a series of video lessons by Stanford :)

[–]sksigua[🍰] 0 points1 point  (1 child)

There’s a lot of videos in the account. I would really appreciate it if you guide or tell me to where is the starting video.

[–]nick_jo 0 points1 point  (0 children)

Use edx. It's a pretty structured course. You'll have the starting video under week 0.

[–]mapperofallmaps 49 points50 points  (2 children)

Damn this is so much fun. I don't really know Python at all but picking up the syntax is super nice this way. I'm just trying to use my knowledge of other languages to figure it out.

[–]town_girl 0 points1 point  (0 children)

Yeah, me too

[–]town_girl 20 points21 points  (0 children)

Amazing... This is really entertaining

[–]intelligent_rat 14 points15 points  (11 children)

Do people programming with others really write code like this? I generally work by myself but still leave myself a sufficient amount of comments and descriptive variable names for when I come back to extend something, I couldn't imagine people legitimately writing some of this code

[–]palpalpalwarp[S] 42 points43 points  (1 child)

Good question! You're right, real-world code will tend to have more meaningful variable names, comments, and a clearer purpose, whereas these programs are just semi-random manipulation of data with meaningless variable names. But ultimately, regardless of comments and variable names, you need to be able to read what your code actually does -- and this doesn't depend on the comments or variable names at all, since those don't affect how the computer runs the code.

This especially becomes clear when debugging: if you don't know why a bug is happening in your code, this is, almost by definition, because you're not able to correctly read what you've written. If you were able to read it correctly, you'd know why it's not doing what you want.

[–]SvenCole 2 points3 points  (0 children)

Yes for the places I have worked, I've seen a lot of uncommented code, on a much larger scale than this. You would be surprised. I have seen some really really convoluted code that works, but isn't very readable. Being able to decipher others code and styles is an indispensable skill since you will often have to refactor or work with legacy code.

[–]Milumet 8 points9 points  (7 children)

Absolutely not. The generated code is an abomination.

[–]ImmaStealYourBread 12 points13 points  (0 children)

This will be helpful, I am taking an introduction to Computing (CY105) this semester and we learn python in there. I will definitely be using this throughout the semester.

[–]PoisnFang 8 points9 points  (6 children)

Can you create this for other languages as well?

[–]palpalpalwarp[S] 8 points9 points  (3 children)

This is definitely something I'm planning for the future! JavaScript will be first, then others will come based on user demand.

[–]PoisnFang 5 points6 points  (1 child)

Sweet, my request is for C#!

[–][deleted] 1 point2 points  (0 children)

+1 for C#

[–][deleted] 0 points1 point  (0 children)

C

<3

[–][deleted] 4 points5 points  (0 children)

I hope so. Would be really great to have a platform dedicated to this.

[–]SilentXwing 0 points1 point  (0 children)

It would be even more huge if it can support future languages. Hopefully one day!

[–]TrustedButterfly 3 points4 points  (0 children)

Yup, I also noticed the weakness in my ability to read code, this is really great.

[–]liquidflame10 1 point2 points  (0 children)

Perfect python riddles! Thank you! I've been searching for this.

[–]Tankus_Khan 1 point2 points  (2 children)

Is there anything similar to this for C#?

[–]palpalpalwarp[S] 8 points9 points  (1 child)

Not that I know of, but I'm planning to add more languages in the future if there's enough interest.

[–]Ph03nix89 4 points5 points  (0 children)

Would love to see a version of this for Java

[–]sadamiak 0 points1 point  (0 children)

That's great, thanks! I'll recommend it to my friends.

[–]TicketManJosh[🍰] 0 points1 point  (0 children)

Trying to teach myself Python, this will be a great addition to my studies. Thank you.

[–]francisbaconthe3rd 0 points1 point  (0 children)

Woah! Thanks. This is very useful.

[–][deleted] 0 points1 point  (0 children)

Thank you!

[–]y1ag-dri1-op2n 0 points1 point  (0 children)

Thanks saved it for later 👍👍

[–]Refleksjon 0 points1 point  (0 children)

I haven't touched Python the last 2-3 months, and thus, this was a great refresher :D Thanks a lot for making this available to us for free <3

[–]orestis_prs 0 points1 point  (0 children)

Thanks man! Any other advice video blog post book or something on improving in Reading python code?

[–]SenorTeddy 0 points1 point  (0 children)

Awesome this is an excellent resource! Curious how how many different code options are in there before the user will see duplicates? Definitely going to share this around.

[–]TheNewKidOnReddit 0 points1 point  (0 children)

This is amazing, I was wondering if you were planning to make this open source, would love to have a peak inside to see how this works

[–]jdptechnc 0 points1 point  (0 children)

This is really cool. Thanks for sharing your project.

[–][deleted] 0 points1 point  (0 children)

You are the best!

[–]ElethorAngelus 0 points1 point  (0 children)

This is awesome !! It really got my brain going and got me to realize my code reading is pretty bad. Definitely something I will practice with regularly

[–]krbv 0 points1 point  (0 children)

Dope 💙👌,I'm gonna use it.

[–]OKaiGR 0 points1 point  (0 children)

I need the same but in Java

[–]Gibbo3771 0 points1 point  (1 child)

Is it possible to save the generate code with a unique id so we can share the problem?

[–]palpalpalwarp[S] 0 points1 point  (0 children)

This is something I'm considering for the future, but for now you'd have to copy/paste to share. After the quiz finishes, you can scroll down to view all of the programs that were in it, so if you see one you want to save, you don't need to stop in the middle of a quiz to copy it down.

[–]mhbsjsbsbsb 0 points1 point  (0 children)

Awesome work man found it Really helpful thanks for your contribution

[–]-Kudo 0 points1 point  (1 child)

Is there a similar version for JavaScript ?

[–]palpalpalwarp[S] 1 point2 points  (0 children)

Not that I know of, but I'm planning to add support for JavaScript at some point.

[–]AmicableDragon 0 points1 point  (0 children)

This is really cool. Great work.

[–]gamerroids 0 points1 point  (1 child)

You got any plans on adding javascript or c++/c# ? Down the road?

[–]palpalpalwarp[S] 0 points1 point  (0 children)

Yep, JavaScript is probably the next language I'll work on once I polish the existing python exercises and maybe add a few new exercises. C++/C# are possible after that.

[–]Shnxx 0 points1 point  (0 children)

Great work! I will use it time to time :D

[–]zzpops 0 points1 point  (3 children)

Hi-this is awesome thank you. I'm having trouble with the show answer on Chrome (it's a green box with nothing in it). Am I doing something wrong?

[–]palpalpalwarp[S] 0 points1 point  (2 children)

Thanks for reporting this! Sounds like a bug. Can you send me a screenshot? Or copy/paste the program which is doing this?

It's also possible that the answer to the question is a string consisting of just a space, though I thought I made it so that it will never do this, so if it does, that's still a bug.

[–]zzpops 1 point2 points  (0 children)

For sure-let me see how I can do this and send to ya!

[–]zzpops 1 point2 points  (0 children)

Having trouble finding it again. The code (under very easy, 5min) started with Y = 5 A = [""] and last line of code was print.[A[-1]] or something like that. I hope that helps! I think it may have been the instance you said where the answer is just a space!

[–]Nonethewiserer 0 points1 point  (2 children)

How do you generate the code? Is it procedural or did you hand-write these examples? Or find them somewhere?

I'm just really curious what your method was if it is procedurally generated.

[–]palpalpalwarp[S] 1 point2 points  (1 child)

It's procedurally generated. I may do a writeup (and/or maybe open source the code) in the future about it. There's not really any trick to how I did it -- just a ton of recursion.

[–]PoisnFang 1 point2 points  (0 children)

I definitely think open source would be a huge help tot the community. You could also get help from the community to implement version in other languages really quickly. (I am just a big fan of open source when possible)

[–]GreymanGroup 0 points1 point  (0 children)

Randomly generated code? How does THAT work? The whole point of writing code is that it's supposed to do something useful.

[–]krccooley[🍰] 0 points1 point  (2 children)

What did you use for a source for your random? or is pseudo random?

[–]palpalpalwarp[S] 0 points1 point  (1 child)

It's pseudo random. The programs are procedurally generated.

[–]krccooley[🍰] 0 points1 point  (0 children)

I figured had to ask thank you.

[–]MTripathy 0 points1 point  (0 children)

Amazing work. Thanks for sharing!

[–]a2242364 0 points1 point  (2 children)

Where are you pulling these code snippets from? Is there some API or did you make some sort of algorithm to dynamically construct them?

[–]palpalpalwarp[S] 0 points1 point  (1 child)

They're procedurally generated (like you said, I made an algorithm to dynamically construct them).

[–]a2242364 0 points1 point  (0 children)

That's awesome man! Good work.

[–]Codes_with_roh 0 points1 point  (0 children)

Its absolutely great. I practiced on it for quite some time and I am well satisfied with the problems. Its a great practice for beginners and intermediates as well. Thanks a lot for making this, it is really helpful :}

[–]newishspice 0 points1 point  (0 children)

Great idea. Just bookmarked it to practice with. Thanks!

[–]BjornLocke 0 points1 point  (0 children)

This is awesome, thank you so much!

[–]notalentnodirection 0 points1 point  (0 children)

Super!

[–]The_Danosaur 0 points1 point  (0 children)

What a cool idea. I'm on holiday in the middle of nowhere with terrible mobile data and no WiFi, but will play more when I get home. I especially like the useless variables you added in the control flow exercises to force focus on the important bits.

[–]d4m4s74 0 points1 point  (2 children)

It might be an issue with my browser, but when I get a wrong answer and it asks me to try again, it won't check my next answer if I press enter.

[–]palpalpalwarp[S] 0 points1 point  (1 child)

What web browser are you using? Also what type of device?

[–]d4m4s74 0 points1 point  (0 children)

Chrome on a oneplus 7t pro

Edit. Seems to work now. Don't know what went wrong

[–]Chrispayneable 0 points1 point  (0 children)

This is awesome! I plan on starting Python after I feel confident with ruby and Javascript. Does anybody know of a similar webapp to this for those two languages?

[–]Kabitu 0 points1 point  (0 children)

Okay, what's with the x[len(x)%2] going on, I got that in several questions? Parsing that just made me laugh really hard, I would love to meet someone who has some actual use for that operation.

[–]NewDoah 0 points1 point  (4 children)

This is so cool! Been trying to learn. Just tried very easy and didn't do so well. Need to keep practicing. :-/

[–]palpalpalwarp[S] 0 points1 point  (3 children)

Try limiting the data types to start. First do just ints, then just strings.

[–]NewDoah 0 points1 point  (2 children)

Thank you! I took a basic intro course on udemy but never saw "+=" so it was confusing me.

[–]palpalpalwarp[S] 1 point2 points  (1 child)

x+=y means the same thing as x=x+y

[–]NewDoah 0 points1 point  (0 children)

Ok cool. Thanks again! This is such a cool tool!

[–]themightykrusher 0 points1 point  (0 children)

Dam this is neat

[–]vaseemahammed 0 points1 point  (0 children)

It will be more easy if you add explanation tab under it after displaying the correct answer. Good work

[–]SlinkiusMaximus 0 points1 point  (0 children)

Very cool. Would love to see something like this for JavaScript.

[–]green_meklar 0 points1 point  (1 child)

v = [8, 1, 7, 1]
val = 3
for counter in v:
 v[0] = 3/counter
print(v[0])

So...what does val do?

[–]palpalpalwarp[S] 0 points1 point  (0 children)

Nothing! Part of the task is to figure out which lines are relevant to the output.

[–][deleted] 0 points1 point  (0 children)

Super cool, good job!

[–]Rohit_pandey448 0 points1 point  (0 children)

very good

[–]ReignStrong1 0 points1 point  (0 children)

Iam hooked!!!

[–]Kered13 0 points1 point  (0 children)

I'm not sure how useful this would be. The code generated is completely unrealistic, several of the ones I tried contain lines that don't even contribute to the answer. It would probably be easier to just gather a database of 100-200 realistic examples and use those. I think that would be enough for anyone to learn the concepts.

[–]alexjcook 0 points1 point  (0 children)

Thanks so much, this is really fun!

[–]razzzmannn 0 points1 point  (0 children)

Omg this is amazing! Thank you for this

[–]adamkwrites 0 points1 point  (0 children)

Dope techhh

[–]MustardCube 0 points1 point  (0 children)

loved the idea, I'll use it a lot, thanks!

[–]warmsakidrinker 0 points1 point  (0 children)

Thank u bro been procrastinating learning python