Jump to content

Challenge: The Student Programmer

camjocotem

You may know how to code, if you were told to write a simple calculator program to do basic arithmetic always using two numbers you'd say "No problem!"

BUT, in the days of yonder many students would try to Copy & Paste ALL THEIR CODE.

 

So! You now as a well-versed coder, could you throw a calculator program together ONLY BY COPYING AND PASTING? :D 

 

Rules: 

-Produce a program which add / multiply / subtract / divide 2 numbers together (ideally comprised of functions that achieve each goal)

-Don't use any library/framework explicitly geared towards math (downloading these would basically complete the challenge)

-You must copy a minimum of one line at a time (no taking parts of lines, I mean what do variables even mean anyway? xD )

-No UI required, a console output is fine

-Use any language of your choice

 

-Must use a minimum of 5 different sources to stitch your program together

or

-Maximum of 4 lines per source (They don't have to be consecutive)

 

-Bonus points for esoteric languages (I mean it all looks confusing anyway right?)

 

 

Feedback would be nice on rules improvements etc etc

I'm just curious to see how difficult it'd be, would love to make this challenge better


 

Link to comment
Share on other sites

Link to post
Share on other sites

idk, seems way to easy right now, maybe add a rule that you must use atleast like 10 different sources or something.

 

Right now i would put "Python calculator example" in Google, and would copy the whole code from that.

I only see your reply if you @ me.

This reply/comment was generated by AI.

Link to comment
Share on other sites

Link to post
Share on other sites

Yeah I suppose that's not a library/framework per se, I'll add that to the rules


 

Link to comment
Share on other sites

Link to post
Share on other sites

can we combine different languages?

 

just add/subtract/multi/div right? 

 

let me give this a try

edit: nope.... just realized how hard it would actually be.

Edited by Saksham
Link to comment
Share on other sites

Link to post
Share on other sites

As long as the result can compile I don't see why you can't mix languages if it just so happens to match the same syntax :)

(Also I accidentally put delete as one of the operators, thanks for helping me notice haha)


 

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, Saksham said:

can we combine different languages?

 

just add/subtract/multi/div right? 

 

let me give this a try

edit: nope.... just realized how hard it would actually be.

Any suggestions on balancing it? 

I'm trying it myself and feeling myself gravitate towards python since it doesn't use brackets.

Maybe I should ease up on the min/max rules?


 

Link to comment
Share on other sites

Link to post
Share on other sites

Here's my attempt

#Taken from https://code4coding.com/python-program-to-add-two-number-using-function/
def add_num(a,b):#function for addition
#Taken from https://www.datacamp.com/community/tutorials/functions-python-tutorial
    return a + b

#Taken from https://stackoverflow.com/questions/37820896/creating-a-multiplying-function-python
def Multiply(num1, num2):
    answer = num1 * num2
    return answer

#Taken from https://www.codexpedia.com/python/python-function-examples/
def divide(a, b):
    return a / b
def substract(a, b):
    return a - b

Divide and subtract felt a bit cheeky to me, I suppose I didn't mention 4 consecutive lines of source, may add that clarification into the rules


 

Link to comment
Share on other sites

Link to post
Share on other sites

Your attempt is not solving the original task to produce a program, @camjocotem - you'd still have to stitch the four methods together.

Write in C.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×