This discussion board is a place to discuss our Daily Challenges and the math and science
related to those challenges. Explanations are more than just a solution — they should
explain the steps and thinking strategies that you used to obtain the solution. Comments
should further the discussion of math and science.
When posting on Brilliant:
Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.
Markdown
Appears as
*italics* or _italics_
italics
**bold** or __bold__
bold
- bulleted - list
bulleted
list
1. numbered 2. list
numbered
list
Note: you must add a full line of space before and after lists for them to show up correctly
i found some interesting TedEx video about coding: Episode10. i found the last episode first, but i assume it's better to watch them from the start ;-) think like a coder
;-) ty. i didnt meant to make an official post. by accident i pressed save instead of edit.
thanks to u i know how to use notes. since then i use notes to test latex before i post it.
before i discovered this, my latex posts had a lot of post-edit-post-edit-post chains.
@num IC
i noticed you have been having problems with this Oren-Ben-Dov guy can you png me as a reply to one of his messages for me and i will leave a nice suprise making sure he does not do that again
i just wrote to him. i assume he just have no idea how to have a fruitful discusion.
i dont want you to "send a surprise". i assume talking to him makes more sense.
but it would be nice if you could teach me, how to surprise someone. ;-)
@Num Ic – Thank you, I'll remember that. This was what my post said from the shifting supports challenge:
Hi again! This was a very helpful reply and it answered my question. Thank you for helping me out (even though my question was confusing to understand) :):)
@Jonathan Eshetu nice, you found the page ;-)
since you know how to code, latex will be easy for you. when u wanna try it, i offer my help.
but anyway i just refered to this page, so we can communicate.
@Jonathan Eshetu
–
;-) here you can chat about everything. there is no off-topic delete like in the daylies.
feel free to ask. there are better coders here, but i will help as good as i can.
i created this page by accident. i just wanted to test the latex output to avoid a post-change-post-chain.
but now i keep it bcs its convenient.
print("Pick two numbers to find the greatest common divisor")a=input()b=input()cd=0a=int(a)b=int(b)ifa>b:foriinrange(1,b+1):ifa%i==0andb%i==0:ifi>cd:cd=ielse:foriinrange(1,a+1):ifa%i==0andb%i==0:ifi>cd:cd=iprint(cd)
@Jonathan Eshetu
–
what is the difference between the condition that i used and your condition?
there is an algorithm from euklid for gcd.
can you implement it as recursive function?
@Jonathan Eshetu
–
i assume u will get that in school soon too.
its about a/b = x + remainder and then divide by the remainder and repeat until the final remainder is 0.
i propose to check the web to find it. i can explain it here, but one approach to programming is to find algorithms and implement them.
@Num Ic
–
Oh ok, so I did some research.
I knew about the euclidean algorithm for finding the gcd, I just didn't know that was the name.
So you want me to implement the euclid approach in python, using recursion (calling a function within itself)?
I'll try.
@Num Ic
–
I used return at first, but I accidentally put
return a
instead of
return(a)
And nothing outputted when I called the function, so I got confused.
@Jonathan Eshetu
–
hm, as far as i know, "return a" and "return(a)" should return the same value. how did u do the box around the return ?
return just returns a value ;-).
to print it, call print(euclidGCD(34, 4))
@Jonathan Eshetu
–
yeah, the calling of your own functions is used the same way as built-in functions.
since you already created code for the daily challenges, you can also check the coding solves by other users. its a good way to get some coding experience just to read coding done by others.
carsten kaminski writes very impressive code. it sometimes took me a while to understand his cool solutions.
@Jonathan Eshetu
–
so check the other codes first. all reading of code helps to get new ideas. (i proposed carstens code just if u wanted to have a challenge.)
@Num Ic
–
I might have the wrong definition of condition, but essentially you checked if it DIDN'T work (a%i != 0 or b%i != 0), from the top down (i -= 1). This allows the program to stop when it finds a value. In my case, I checked if it DID work (a%i == 0 and b%i == 0) and went from the bottom up (for i in range(1, b+1)). Since we're looking for the GREATEST common divisor, going from the top down allows you to stop when you find a value, because that value is already the greatest possible number.
@Jonathan Eshetu
–
nice solution for the first problem.
for the second: its a nice example to show that it might cause problems if a function is used as argument for the function itself.
the return value is 3 + something. so i checked what happened if n=3.
_ = 4 will result in return 0 -> no problem
_ = 3 will result in return 0 -> no problem
_ = 2 will result in return 3+something -> might cause a problem
but you can also use a loop and call the function with different values to check the results. i do this sometimes to figure out if there might be an error.
have u checked the russian course?
The reason it's 2 is because eventually, the program will simplify to
3 + rec(3)
Because when you keep subtracting the number, it will eventually go below 0, and then everything will simplify to the above equation. But when you calculate the return value, it becomes 3 + 3 + rec(rec(3-_), and if the blank is less than 3, it will result in rec(natural number), which causes an infinite loop.
Eg.
3 + rec(rec(5-3));
3 + rec(rec(2));
3 + rec(3 + rec(rec(2-3)));
3 + rec(3 + rec(rec(-1)));
3 + rec(3 + 0);
3 + rec(3) (it always simplifies to this);
3 + rec(rec(3-3))) (since the blank is 3, the rec function goes down to 0);
3 + 0;
3;
However, if it was say 2;
3 + rec(3);
3 + rec(rec(3-2));
3 + rec(rec(1));
3 + rec(3 + rec(rec(1-3)));
3 + rec(3 + rec(rec(-2)));
3 + rec(3 + 0);
3 + rec(3);
Hence the infinite loop.
@Jonathan Eshetu
–
very good, you got it.
u can also test it in the coding environment here.
nothing bad will happen. there will just be a message that there are too much recursions.
i did the test with _=4 and n=10000.
@Num Ic
–
Oh wow. I just used IDLE to play around and see what happened. I set a variable that increased 1 for ever recursion. and then made it stop at 20 so I could review the loop.
@Jonathan Eshetu
–
yeah for local test, i used idle too. but here i use the brilliant coding environment.
have u seen that carsten proposed two webpages?
have u checked the community for coding problems, that are posted by the members?
@Num Ic
–
I've looked around here and there for problems posted by members, but everything is either WAY too easy or WAY too hard.
A website I just found out, that I'm going to use a lot now, is edabit.com. It has a bunch of different challenges anywhere from Very Easy -Expert, with a ton of different languages.
@Jonathan Eshetu
–
i do linebreaks by two spaces and then return. 4 spaces should create a linebreak too.
i had four spaces before the 4, but it seems not to work.
btw: u can test such things by creating a note.
but u can do it here too ;-)
(if the others in this chat are annoyed, they will unsubscribe this chat)
@Jonathan Eshetu
–
questions are rarely stupid. if the factorial function is called with the input 10, then it calls itself 10 times, if it is called with 100, then it calls itself 100 times. the recursion depth is how often a function calls itself until it finishes.
eg factorial 4:
remember the 4 and call f(3)
remember the 3 and call f(2)
remember the 2 and call f(1)
return 1
return the remembered 2 multiplied by 1 (=2)
return the remembered 3 multiplied by 2 (=6)
return the remembered 4 multiplied by 6 (=24)
@Num Ic
–
Now that sounds fun. Though, I'm a bit busy with schoolwork rn, so I'll make the recursion depth program and solve that problem when I get s'more work done.
@Jonathan Eshetu
–
sure. schoolwork first.
this is a proposal for a coding environment: repl.it
this is for learning: realpython.com
(the 2nd seems to be similar to your edabit.com)
@Mahdi Raza hello Mahdi Raza , you created a very nice animation in this daily problem: Sum These Segments. what tool can be used to create such an animation? or did you move the lines by hand, step-by-step?
this is great ty. i checked your pentagon. there you mentioned keynote. i thought that was only a kind of a powerpoint clone. but you are creating very impressive animations. ty for that and ty for the hint.
yeah. and it is faster, since a function call takes more time than a loop.
it is just used as a simple way to understand recursions.
you can also use carstens codes to understand recursions ;-)
ty, i didnt check realpython. i just saw that one did recommend it.
for recursion depth, a simple code is enough. just dont be affraid.
# Inputa=[]# This is an array so we can print the values if neededdefrec(n):a.append(n)ifn<=0:return0return3+rec(rec(n-3))forxinrange(1,50):print(x,"-",rec(x),len(a))a.clear()# Output1-332-333-334-675-676-677-9158-9159-91510-123111-123112-123113-156314-156315-156316-1812717-1812718-1812719-2125520-2125521-2125522-2451123-2451124-2451125-27102326-27102327-27102328-30204729-30204730-30204731-33409532-33409533-33409534-36819135-36819136-36819137-391638338-391638339-391638340-423276741-423276742-423276743-456553544-456553545-456553546-4813107147-4813107148-4813107149-51262143
@Num Ic
–
After analyzing:
1) Since it's steadily increasing, isn't the depth infinite?
2) This is crazy. If you add 1 to each of the depths, you end up with a very noticeable pattern.
4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64...
Why would powers of 2 appear here?
@Jonathan Eshetu
–
i have to think about the logic to understand why the powers of 2 occure here.
but there is a missunderstanding. my intention was not to check the depth of this particular function. (50 is much too low to test this one).
its more easy to use a simple function that just increases the given value.
@Jonathan Eshetu
–
hm yeah it was just an idea. i thought it might be interesting for you to know how to check the limits of python (or any ide).
currently i feel a bit incapable bcs i am not able to express that intention clear enough.
have you found some interesting tasks on edabit.com?
@Num Ic
–
There was 1 problem, something like "create a stutter function that gets a parameter, and returns the first 2 letters, ..., the first 2 letters again, ..., and then the full word with a question mark.
Ex. stutter(python) -> py...py...python?
I have the idea, I just don't exactly know how to code it.
defninjaToEnglish(phrase):engText=[]ninjaDict={"a":"ka","b":"u","c":"mi","d":"te","e":"ku","f":"lu","g":"ji","h":"ri","i":"ki","j":"zu","k":"me","l":"ta","m":"rin","n":"to","o":"mo","p":"no","q":"ke","r":"shi","s":"ari","t":"chi","u":"do","v":"ru","w":"mei","x":"na","u":"fu","z":"zi"," ":" ",}phrase=phrase.split('~')foriinphrase:forkey,valueinninjaDict.items():ifi==value:engText.append(key)engText=''.join(engText)returnengTextprint(ninjaToEnglish("chi~ri~ku~ ~ka~to~ari~mei~ku~shi~ ~chi~mo~ ~chi~ri~ki~ari~ ~no~shi~mo~u~ta~ku~rin~ ~ki~ari~ ~ari~ki~na~ ~te~ki~ru~ki~te~ku~te~ ~u~fu~ ~ri~ka~ta~lu"))#output: the answer to this problem is six divided by half (I almost put 3)
@Jonathan Eshetu
–
what does this?: engText = ''.join(engText)
and ty: i was not aware that there is no direct access from value to key.
i assume that is why they created that reverse dict in the solution.
Basically, it takes a number, returns its divisors, the sum of its divisors, and if it's a perfect number (a number where the sum of its divisors equals itself) or not.
1
2
defperfectNumberCheck(n):print(n,"\n","divisors:",' '.join(map(str,[iforiinrange(1,n)ifn%i==0]+[n])),"\n","sum of divisors (aside from itself):",sum([iforiinrange(1,n)ifn%i==0]),"\n","Perfect number:","True"ifsum([iforiinrange(1,n)ifn%i==0])==nelse"False","\n","\n")
very cool.
its possible to skip long lines by using \
and i know that for some ppl it is a challenge to solve problems in few lines, but it is more easy to read code if it is split into several commands.
and i m impressed: you already know more about how to use the print command than i do.
so i should try to catch up again ;-)
@Jonathan Eshetu
–
Here it is a bit..neater, because I assigned the divisors array so I wouldn't have to spam it.
1
defperfectNumberCheck(n):divisors=[iforiinrange(1,n)ifn%i==0]+[n];print(n,"\n","divisors:",' '.join(map(str,divisors)),"\n","sum of divisors (aside from itself):",sum(divisors)-n,"\n","Perfect number:","True"ifsum(divisors)-n==nelse"False","\n")
@Jonathan Eshetu
–
hm, i had to find some.
i really recommend the corrected coursera page that i posted. coursera learn python
that was one task i liked: korovay
it has to return correct russian word for cow (korov, korova or korovy):
For a given number n <100, finish the phrase “Grazing in the meadow ...” with one of the possible continuation: “n cows”, “n cow”, “n cows”, correctly declining the word “cow”.
Input format
A natural number is entered.
Output format
The program should print the entered number n and one of the words: korov, korova or korovy. There must be exactly one space between the number and the word.
Note
If Russian is not your native language and you find it difficult to cope with this task, you can find a hint on declensions here: https://www.coursera.org/learn/python-osnovy-programmirovaniya/programming/rsYze/korovy/discussions/threads/-FJYlWcKEeiMwRLm6nkdwA .
"n коров" if 10 <n <20 or the last digit of n is one of 0, 5, 6, 7, 8, 9.
"n корова" if the last digit n == 1.
"n коровы" in all other cases.
@Jonathan Eshetu
–
;-) yeah, the same happened to me when i translated the page.
its a double challenge to code, when the task is given in a foreign language ;-)
i saved some of the tasks, but i saved them translated to german not english ;-(
@Percy Jackson you asked for sides to learn python.
i did the free course on this page: coursera.org
it is in russian, but i translated the pages (i ignored the videos)
a member here recommended edabit.com (it seems to be a free page to learn python).
other pages:
realpython.com (might be pay to use)
repl.it (online coding environment)
@Percy Jackson ty for showing your javascript code for the candy problem.
it helped me a lot to understand javascript.
i found a nice solution to change the speed.
if you want to see it, i can post it here.
@Percy Jackson@Jonathan Eshetu
i m not sure if i linked the correct coursera course.
this is the one i did: https://www.coursera.org/learn/python-osnovy-programmirovaniya/home/welcome
@Mitch Connor
I have deleted my solution for the problem, but I apologize for the incorrect equation. I got them mixed up, which is completely my bad. Thanks for telling me!
I can't stay for long, so sorry if i don't respond, but say I was making a text rpg in python
in this rpg, i plan to have an effects system, ex. an attack inflicting the opponent with burn, poison, freeze, etc. etc.
what would you say is the most efficient way to do this?
the player has a class, so you can add attributes if necessary. here is the class code (done by me)
as you can see, i have effects in the attack setting, but how should i go about adding it in an actual battle?
going through a bunch of if statements (if attack[2] =="Burned", if attack[2] == "Freezed", etc. etc.)
making a dict to match effect name with effects?
thank you in advance! I have to go now, so i'll respond tmrw morning!
@Jonathan Eshetu
–
if they cause the same effect then you could use if attack[2] in ....
if the effects are different then a dict sounds like a good idea.
@Num Ic
–
You're obviously more advanced at this then me, lol
so this is all being done on repl.it (remember that), so if you have an account, I can invite you to the repl ;)
however, i'm not the owner, so i'll have to wait until the owner gets online.
@Num Ic
–
it's not only rpg, you're just advanced in coding in general.
so would you like to join? i'd invite you some time tmrw, and we could really use the help lol. i understand if you say no ;-)
@Jonathan Eshetu
–
oh, i love to join. its just that seeing you young guys doing all this cool stuff makes me feel i miss a lot that i should have done when i was younger.
i ll try to find some energy to create an repl acc.
@Jonathan Eshetu
–
ty for checking. its not late. i was just curious bcs they updated the wording already some days ago, so i was wandering if there was more then just marking it as resolved. ty again
Yeah, I set it to .split(" + "), .split(" - "), and .split(" = "), so that's why it does that. If I remove the spaces, it might count them as numbers...
@Paul Romero Bello sry for the deleted msg, i tried to get your mention id, to "invite" you to this note.
the 2 links in this note are very helpful. i found some more too. and i can help whenever you are ready to try some latex.
additional: an idea to post a solution without pictures would be:
51234
23451
12345
34512
45123
lol, the numbers where just cycling. i have not recognized that before.
@Num Ic
–
Yeah, I realized how it works by myself. Now, I am taking notes from your post. I hope to post a solution for tomorrows problem, if I get it right, of course!!!
@Jonathan Eshetu
–
very nice. ty for that idea.
i don't mind the pings. i enjoy the interaction with you two. @Paul Romero Bello please feel free to try it too.
if you don't want to get pings from this note, then you can click "unsubscribe", but i'm not sure what kind of notifications you will still get then.
maybe you want to use this. just an alternative to using percy's ;-)
i'm still curious. i assume a mac has a screenshot function?
else you might have something similar like snip&sketch:
when the "print" button is pressed, it offers some screen capture options.
i don't have a mac, but the web says shift-command-3 create a screenshot.
u said u use a pc-keyboard, so i assume the command key is different from the funktion key. is it?
Thanks for the link. The way I interpreted it was this: take any group of two students, there are 60/2=30 and there are 60 x 3 = 180 possible answers of which 60 x 2 =120 correct whatever the distribution. 60 answers are either all right, all wrong, or a combination of right and wrong. Person A could get Q1 right, and person B could get Q2 right. That's 2 questions right between 2 students. Or, A and B both got Q1 right but C and D got Q2 right. Or, if person A got Q1 right, B got Q2 right, and C got Q3 right, then D could have gotten Q1 or Q2 right or even Q3. I'm probably making too much out of this.
i just copy the statement, so it's more easy to compare.
"During an examination, 60 students had to answer 3 questions. After the examination, it's shown that for any two students, there is always at least 1 question which both students could solve."
it deprnds on the original wording but 60/2 is dividing the 60 students into groups of 2.
but any two students would be 60*59/2 (combinatorics: pick 2 out of 60).
so this is much more than 30.
regarding the 1 question that both could solve. the wording indicates that both had the same question correct.
and as i said: the total number of questions is not stated. it could be the 3 same questions for all 60 students, but it could be more depending on the conditions of the problem.
the problem like you described it sounds more like:
60 students are divided into groups of 2.
each group had to answer 3 questions. both students answered individually.
every student gave at least one correct answer.
i was used to program in basic and c, but python is very nice.
i'm still on my way to understand how to use python-goodies like range and permutation.
but please feel free to ask questions regarding coding. it would be a pleasure for me to help you.
Thank you. Long ago (30 years) I used Fortran, Watfive, Pascal and Pascal took the lead. I got into a lot of Finite Element modeling with programming but quickly canned programs came on the scene in the form of software. So, I drifted away from programming and relied on software. But I'm impressed with the flexibility Python offers and want to learn it. Been doing a little here and there but get lost in the goodies (permutations and other libraries). I'll be sure to take you up on that with questions as they arise. Thanks again!
@Joe Byrne
–
nice i used pascal too. i have seen fortran but never used it. is/was it fun to work with it?
i dont know watfive. i will search that.
you said you'r a bridge engineer. that sounds very interesting.
@Num Ic
–
Watfiv had some additional features over Fortran but as Fortran indicates "formula translation" was its main feature. With advent of Pascal working with arrays took on new meaning. Bridges are fun because they encompass so many aspects of civil engineering, structural, hydraulic, highway, geotechnical and it all has to be designed around those criteria. Kind of like a puzzle with constraints.
@Joe Byrne
–
i could find some fortran code samples. i'm glad that i could mainly understand them.
fortran whatF iv was harder to find, they looked a bit like assembler code.
hm i assume 180 is the maximum if all student get different questions.
(there might be more but that should be mentioned like: ... had to answer 3 questions out of a set of questions.)
my first assumption was: all students get the same 3 questions.
i still assume this is the idea. but i have no idea what the question behind that setting is.
is this the original wording or is it just a draft for a challenge that you prepare?
It's the actual wording of a problem in the challenges community I believe under logic. The writer intended for the groups of two to get the same question right. But I thought there could be different interpretations.
"there is always at least 1 question which both students could solve."
--> implies that each student had at least 1 question solved.
--> if even one of them only scored 1/3, then that particular question must be solved by 59 others to make this claim true. We can see this in just a group of three, let ABC be the students and 123 the questions. Say q1 is the easiest one, so average students A and B could only manage that one. But even when brilliant C solved the other difficult two, but made careless mistake / ran out of time on q1, the claim will be invalid (A1, B1, C23).
--> if there are no 'easy' question which is scored by ALL the students, then all 60 must have solved AT LEAST 2 questions each.
Thank you, Joe, but that compliment is too high for me. I am still struggling when confronted with questions under category group theory. Too much lines and nodes than I can handle. And sorry I didn't think deeper than taking it as the 60 are just the usual class of hs students answering the same 3 questions. Perhaps the assumptions brought along from Three Questions problem we just had around Xmas.
@Saya Suka
–
I liked that problem around Xmas but then there was more information to give a certain exactness. My approach is always to flesh out the knowns so when confronted with abstractions I'm in unchartered territory.
regarding 'beating a dead horse': hint: each char is coded as 2 digit number.
meaning: to waste effort on something when there is no chance of succeeding.
(beat a dead horse)
(i assume he wants to say that there is no benefit in discussing the different ways of solving the challenges. - in my opinion the expression does not fit here very well.)
in old times some riders did beat a horse to make it run faster, but if the horse is already done then this will have no effect.
Expression means "We've discussed this so much and in so many ways but aren't making any progress." I value different approaches and don't understand why people think they have the ultimate solution. It's like asking, "who's better - the republican or democratic nominee? Obviously it depends on what you value. So, I'm advocating that all approaches that yield the correct answer are valuable. The lengthy one that experts find redundant appeals to the person who lacks that knowledge to solve. The programmer who has solved many cryptograms and is honing his programming skills is saving time but providing knowledge to those who don't know programming. Etc.
@Joe Byrne
–
good point. i assumed by 'beating a dead horse' you meant that that discussion has no positive effect.
my hope is that the discussion helps the critic to understand that there is a value in presenting different solutions (even coded ;-).
Thanks, num IC! For the horse proverbs explanation and the hint, but still I'm getting no progress. I don't understand 2 parts there, one is the many 7 there (though your reply had an almost balanced quantity of 6 & 7), and the other is why there are abcd included there too.
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i-1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
Sort by:
Top Newesti found some interesting TedEx video about coding: Episode10. i found the last episode first, but i assume it's better to watch them from the start ;-) think like a coder
Log in to reply
ah, that, I've already watched the whole series before ;)
Log in to reply
Nice & helpful discussion @num IC
Log in to reply
;-) ty. i didnt meant to make an official post. by accident i pressed save instead of edit.
thanks to u i know how to use notes. since then i use notes to test latex before i post it.
before i discovered this, my latex posts had a lot of post-edit-post-edit-post chains.
Log in to reply
I have deleted the chatbot discussion .Is there any problem or it is fine?
Log in to reply
Your welcome.
Log in to reply
□⊕∇⊘O◊Δ⊖⊗⊙ ∗∘△ΘΞΦΩ
□⊕∇⊘O◊Δ⊖⊗⊙ ∗∘△ΘΞΦΩ
Log in to reply
its all fine. ty again for the idea of creating a chatbot. when i find some spare time i ll try to implement it, like it is shown in the video.
Log in to reply
Your huge welcome!
Log in to reply
andendswith:200 lol
Log in to reply
Very simple latex
Log in to reply
;-) and can be copied (-;
Log in to reply
@num IC i noticed you have been having problems with this Oren-Ben-Dov guy can you png me as a reply to one of his messages for me and i will leave a nice suprise making sure he does not do that again
Log in to reply
i just wrote to him. i assume he just have no idea how to have a fruitful discusion.
i dont want you to "send a surprise". i assume talking to him makes more sense.
but it would be nice if you could teach me, how to surprise someone. ;-)
Log in to reply
no it is solely on;y for me and percy as hamza has disgraced us and leaked it to another person specificly going against what it is for
Log in to reply
@mention[10644076:Toska Pi] i cannot see your post since i m no premium member, if you have a question, please feel free to post it here.
Log in to reply
@Num Ic – Thank you, I'll remember that. This was what my post said from the shifting supports challenge: Hi again! This was a very helpful reply and it answered my question. Thank you for helping me out (even though my question was confusing to understand) :):)
Log in to reply
as i remember: the question was about "fixed CoM". you are welcome, i m glad that i could help
Log in to reply
Latex is a bit confusing, to be honest. I don't really get it, but I don't think I need it much for Brilliant solution posting.
Log in to reply
@Jonathan Eshetu nice, you found the page ;-)
since you know how to code, latex will be easy for you. when u wanna try it, i offer my help.
but anyway i just refered to this page, so we can communicate.
Log in to reply
Thanks! :)
Can I also chat to you on here about python, instead of just latex? Just in case I have any questions.
Log in to reply
feel free to ask. there are better coders here, but i will help as good as i can.
i created this page by accident. i just wanted to test the latex output to avoid a post-change-post-chain.
but now i keep it bcs its convenient.
Log in to reply
Heyo, someone give me a problem to solve with python.
Log in to reply
what about the daily challenges?
Log in to reply
I've already completed most of the ones that you could solve with programming...but thanks for the suggestion.
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
I'm assuming you meant b%i by the way.
Log in to reply
its not my intention to make u feel stupid.
Log in to reply
there is an algorithm from euklid for gcd.
can you implement it as recursive function?
Log in to reply
What does euklid and recursive mean?
Log in to reply
its about a/b = x + remainder and then divide by the remainder and repeat until the final remainder is 0.
i propose to check the web to find it. i can explain it here, but one approach to programming is to find algorithms and implement them.
Log in to reply
Log in to reply
Log in to reply
very good. you are fast. i would return the gcd, so it can be used instead of print, but as i said: very good and quick
Log in to reply
return a
instead ofreturn(a)
And nothing outputted when I called the function, so I got confused.Log in to reply
return just returns a value ;-).
to print it, call print(euclidGCD(34, 4))
Log in to reply
Log in to reply
to use it, it would be like:
g = euclidGCD(8, 4)
Log in to reply
Log in to reply
since you already created code for the daily challenges, you can also check the coding solves by other users. its a good way to get some coding experience just to read coding done by others.
carsten kaminski writes very impressive code. it sometimes took me a while to understand his cool solutions.
Log in to reply
Log in to reply
Log in to reply
like this
Log in to reply
thank you
, i didnt know thatLog in to reply
most certainly
welcome. I found it out on accident :)Log in to reply
Log in to reply
Log in to reply
Log in to reply
coursera.org
i did the free course on this page:it is in russian, but i translated the pages (i ignored the videos)
Log in to reply
I've just been using Brilliant's python course and self-study, but that seems better.
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
i just found this: Using Recursion (Python loop) and this: Break the Code
Log in to reply
Could you please explain, if you got it? I'm just scratching my head right now...
Log in to reply
for the second: its a nice example to show that it might cause problems if a function is used as argument for the function itself.
the return value is 3 + something. so i checked what happened if n=3.
_ = 4 will result in return 0 -> no problem
_ = 3 will result in return 0 -> no problem
_ = 2 will result in return 3+something -> might cause a problem
but you can also use a loop and call the function with different values to check the results. i do this sometimes to figure out if there might be an error.
have u checked the russian course?
Log in to reply
If n = 5, then 4 3 and 2 all result in leaving something....right?
And no, I haven't checked the course out, sorry! I'll get to that soon.
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
The reason it's 2 is because eventually, the program will simplify to
3 + rec(3)
Because when you keep subtracting the number, it will eventually go below 0, and then everything will simplify to the above equation. But when you calculate the return value, it becomes
3 + 3 + rec(rec(3-_)
, and if the blank is less than 3, it will result in rec(natural number), which causes an infinite loop. Eg.3 + rec(rec(5-3)); 3 + rec(rec(2)); 3 + rec(3 + rec(rec(2-3))); 3 + rec(3 + rec(rec(-1))); 3 + rec(3 + 0); 3 + rec(3) (it always simplifies to this); 3 + rec(rec(3-3))) (since the blank is 3, the rec function goes down to 0); 3 + 0; 3; However, if it was say 2; 3 + rec(3); 3 + rec(rec(3-2)); 3 + rec(rec(1)); 3 + rec(3 + rec(rec(1-3))); 3 + rec(3 + rec(rec(-2))); 3 + rec(3 + 0); 3 + rec(3); Hence the infinite loop.
Log in to reply
u can also test it in the coding environment here.
nothing bad will happen. there will just be a message that there are too much recursions.
i did the test with _=4 and n=10000.
Log in to reply
Log in to reply
have u seen that carsten proposed two webpages?
have u checked the community for coding problems, that are posted by the members?
Log in to reply
A website I just found out, that I'm going to use a lot now, is edabit.com. It has a bunch of different challenges anywhere from Very Easy -Expert, with a ton of different languages.
Log in to reply
Log in to reply
Log in to reply
@num IC this explanation was actually a bit off, as the pattern goes:
3 + rec(3)
3 + 3 + rec(rec(3-3))
3 + 3 + 0
6
or in some cases;
3 + rec(3 + rec(3))
3 + rec(3 + 3 + rec(rec(3-3)))
3 + rec(6)
3 + 3 + rec(rec(6-3)
3 + 3 + rec(rec(3))
3 + 3 + rec(3 + rec(rec(3-3)))
3 + 3 + rec(3)
3 + 3 + 3 + rec(rec(3-3))
3 + 3 + 3 + 0
9
But I'm assuming you see the pattern by now.
Log in to reply
Log in to reply
i had four spaces before the 4, but it seems not to work.
btw: u can test such things by creating a note.
but u can do it here too ;-) (if the others in this chat are annoyed, they will unsubscribe this chat)
Log in to reply
the recursion depth is limited, so big input values will cause a problem even with _=3 and _=4.
task: create a short code to find the max recursion depth.
Log in to reply
Log in to reply
eg factorial 4:
-> recursion depth 4
Log in to reply
Log in to reply
can you solve this with python?
maybe this is better
Log in to reply
Log in to reply
Log in to reply
this is a proposal for a coding environment: repl.it
this is for learning: realpython.com
(the 2nd seems to be similar to your edabit.com)
Log in to reply
I need to test my programming skills.
Log in to reply
i can sure propose something, but i would prefer if people use "please" when they ask for something.
Log in to reply
Sorry about that.
I was a bit....impatient when I wrote that. Completely my fault. Could you please?
Log in to reply
@Mahdi Raza hello Mahdi Raza , you created a very nice animation in this daily problem: Sum These Segments. what tool can be used to create such an animation? or did you move the lines by hand, step-by-step?
Log in to reply
Hi, I have used Keynote. I grouped the lines and then rotated. Refer this if you have any more questions
Log in to reply
this is great ty. i checked your pentagon. there you mentioned keynote. i thought that was only a kind of a powerpoint clone. but you are creating very impressive animations. ty for that and ty for the hint.
Log in to reply
Log in to reply
@num IC It was getting cramped earlier, so I'm just making a new post to continue our conversation.
1) I checked out repl.it, it seems pretty helpful, but realpython seems like basically pay to python.
2) Still working on those 2 problems by the way (smallest 10-digit number and recursion depth.) :)
3) I was thinking earlier, isn't there a much easier factorial function?
Log in to reply
yeah. and it is faster, since a function call takes more time than a loop.
it is just used as a simple way to understand recursions.
you can also use carstens codes to understand recursions ;-)
ty, i didnt check realpython. i just saw that one did recommend it.
for recursion depth, a simple code is enough. just dont be affraid.
Log in to reply
Here's the program I used for the 10 digit problem:
Log in to reply
Log in to reply
Log in to reply
And isn't the recursion depth infinite?
As for any number, it would keep subtracting _ until the number became <= 0, and the number could be infinitely large...
Log in to reply
Log in to reply
For starters, I edited the function a little bit, so that it measures how many times the function is called.
Log in to reply
1) Since it's steadily increasing, isn't the depth infinite?
2) This is crazy. If you add 1 to each of the depths, you end up with a very noticeable pattern.
4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64... Why would powers of 2 appear here?
Log in to reply
but there is a missunderstanding. my intention was not to check the depth of this particular function. (50 is much too low to test this one).
its more easy to use a simple function that just increases the given value.
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
currently i feel a bit incapable bcs i am not able to express that intention clear enough.
have you found some interesting tasks on edabit.com?
Log in to reply
Don't feel incapable, if anything my limited python vocab is stopping me from understanding.
I've just been doing easy tasks for now on edabit, but I've started switching a bit more to repl.it
Log in to reply
do you reccomend them? do you have questions?
Log in to reply
Ex. stutter(python) -> py...py...python?
I have the idea, I just don't exactly know how to code it.
Log in to reply
print(t[:2]) what did u use to get the first 2 letters?
Log in to reply
Log in to reply
Log in to reply
a string is an array, just filled with chars
Log in to reply
Log in to reply
Log in to reply
this is a good idea to train using strings and dictionaries:
https://brilliant.org/problems/you-ninja-name/
Log in to reply
sorry this is so late.
Log in to reply
Log in to reply
Log in to reply
and ty: i was not aware that there is no direct access from value to key.
i assume that is why they created that reverse dict in the solution.
Log in to reply
Log in to reply
Log in to reply
Log in to reply
engText = ""
and then:
engText += key
but good to know how to convert an array into a string.
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Hey @num IC, I finally made a one liner!
Basically, it takes a number, returns its divisors, the sum of its divisors, and if it's a perfect number (a number where the sum of its divisors equals itself) or not.
Try it out!
Log in to reply
very cool.
its possible to skip long lines by using \
and i know that for some ppl it is a challenge to solve problems in few lines, but it is more easy to read code if it is split into several commands.
and i m impressed: you already know more about how to use the print command than i do.
so i should try to catch up again ;-)
Log in to reply
I knew I could make the code a lot more compact if it was in several lines, but I wanted to see if I could do it in one, yknow?
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
i really recommend the corrected coursera page that i posted.
coursera learn python
that was one task i liked:
korovay
it has to return correct russian word for cow (korov, korova or korovy):
For a given number n <100, finish the phrase “Grazing in the meadow ...” with one of the possible continuation: “n cows”, “n cow”, “n cows”, correctly declining the word “cow”.
Input format
A natural number is entered.
Output format
The program should print the entered number n and one of the words: korov, korova or korovy. There must be exactly one space between the number and the word.
Note
If Russian is not your native language and you find it difficult to cope with this task, you can find a hint on declensions here: https://www.coursera.org/learn/python-osnovy-programmirovaniya/programming/rsYze/korovy/discussions/threads/-FJYlWcKEeiMwRLm6nkdwA .
"n коров" if 10 <n <20 or the last digit of n is one of 0, 5, 6, 7, 8, 9.
"n корова" if the last digit n == 1.
"n коровы" in all other cases.
Log in to reply
Log in to reply
Log in to reply
Log in to reply
its a double challenge to code, when the task is given in a foreign language ;-)
i saved some of the tasks, but i saved them translated to german not english ;-(
Log in to reply
@Percy Jackson you asked for sides to learn python.
i did the free course on this page: coursera.org
it is in russian, but i translated the pages (i ignored the videos)
a member here recommended edabit.com (it seems to be a free page to learn python).
other pages:
realpython.com (might be pay to use) repl.it (online coding environment)
Log in to reply
@Percy Jackson ty for showing your javascript code for the candy problem.
it helped me a lot to understand javascript.
i found a nice solution to change the speed.
if you want to see it, i can post it here.
Log in to reply
Ok, you can post it here. Thanks :)
Log in to reply
Thanks :)
Log in to reply
javascript:
Log in to reply
Log in to reply
I wish you success with your exams.
Log in to reply
Log in to reply
@Percy Jackson @Jonathan Eshetu
i m not sure if i linked the correct coursera course.
this is the one i did: https://www.coursera.org/learn/python-osnovy-programmirovaniya/home/welcome
Log in to reply
@Mitch Connor
I have deleted my solution for the problem, but I apologize for the incorrect equation. I got them mixed up, which is completely my bad. Thanks for telling me!
Log in to reply
Hey @num IC , I have a quick question, if you're here
Log in to reply
hi. i m here now.
but since i still have to understand some of the lines from your cool code, i m not sure if i really still can help you ;-)
Log in to reply
haha, thanks ;-)
I can't stay for long, so sorry if i don't respond, but say I was making a text rpg in python
in this rpg, i plan to have an effects system, ex. an attack inflicting the opponent with burn, poison, freeze, etc. etc.
what would you say is the most efficient way to do this? the player has a class, so you can add attributes if necessary. here is the class code (done by me)
Log in to reply
as you can see, i have effects in the attack setting, but how should i go about adding it in an actual battle? going through a bunch of if statements (if attack[2] =="Burned", if attack[2] == "Freezed", etc. etc.) making a dict to match effect name with effects? thank you in advance! I have to go now, so i'll respond tmrw morning!
Log in to reply
if the effects are different then a dict sounds like a good idea.
Log in to reply
Log in to reply
so this is all being done on repl.it (remember that), so if you have an account, I can invite you to the repl ;)
however, i'm not the owner, so i'll have to wait until the owner gets online.
Log in to reply
Log in to reply
Log in to reply
so would you like to join? i'd invite you some time tmrw, and we could really use the help lol. i understand if you say no ;-)
Log in to reply
i ll try to find some energy to create an repl acc.
Log in to reply
Life's sometimes that way, but who says you can't do all those things this year, or maybe more?
Plus, you don't have to worry about final exams ;-)
Log in to reply
Log in to reply
Log in to reply
could you do me a favour and check what brilliant has written here? https://brilliant.org/daily-problems/circles-parallelogram/?from_notification=15616976#!/dispute-comments/36816/
i cant check because i dont have premium
Log in to reply
I've marked this report as resolved."
Log in to reply
Log in to reply
don't forget to tell me if you make a repl acc lol
Log in to reply
i checked if your nice solutions runs in bril env.
i used that as input:
and it worked well. i tried this too:
and got 0 solutions.
it does not matter for the designed purpose, but i assume u will process input data in the future too.
Log in to reply
Yeah, I set it to
.split(" + "), .split(" - "), and .split(" = ")
, so that's why it does that. If I remove the spaces, it might count them as numbers...Log in to reply
Log in to reply
Log in to reply
@Paul Romero Bello sry for the deleted msg, i tried to get your mention id, to "invite" you to this note.
the 2 links in this note are very helpful. i found some more too. and i can help whenever you are ready to try some latex.
additional: an idea to post a solution without pictures would be:
51234
23451
12345
34512
45123
lol, the numbers where just cycling. i have not recognized that before.
Log in to reply
You are very kind. Thank you :)
Log in to reply
you are very welcome.
first "challenge": copy the next line and send it as reply
\(\boxed{\LaTeX}\)
Log in to reply
LATEX
Log in to reply
Log in to reply
voila, your first latex post :)
did you check how it works? or maybe you know it without reading the links.
Log in to reply
Log in to reply
Log in to reply
LATEX
wait, i'm a bit confused onhow exactly does it work?
Log in to reply
so what if I...
LATEX
Log in to reply
Log in to reply
abcdefghij
Log in to reply
Log in to reply
Log in to reply
upmiddlelow
very good. can you do this?:Log in to reply
upmiddlelow ?
hm....Log in to reply
Log in to reply
upmiddlelow
Log in to reply
Log in to reply
highesthigherhighmiddlelowlowerlowest
Log in to reply
highesthigherhighmiddlelowlowerlowest
i have to try thatLog in to reply
i don't mind the pings. i enjoy the interaction with you two.
@Paul Romero Bello please feel free to try it too.
if you don't want to get pings from this note, then you can click "unsubscribe", but i'm not sure what kind of notifications you will still get then.
Log in to reply
maybe you want to use this. just an alternative to using percy's ;-)
i'm still curious. i assume a mac has a screenshot function?
else you might have something similar like snip&sketch:
when the "print" button is pressed, it offers some screen capture options.
Log in to reply
i don't have a mac, but the web says shift-command-3 create a screenshot.
u said u use a pc-keyboard, so i assume the command key is different from the funktion key. is it?
Log in to reply
Thanks for the link. The way I interpreted it was this: take any group of two students, there are 60/2=30 and there are 60 x 3 = 180 possible answers of which 60 x 2 =120 correct whatever the distribution. 60 answers are either all right, all wrong, or a combination of right and wrong. Person A could get Q1 right, and person B could get Q2 right. That's 2 questions right between 2 students. Or, A and B both got Q1 right but C and D got Q2 right. Or, if person A got Q1 right, B got Q2 right, and C got Q3 right, then D could have gotten Q1 or Q2 right or even Q3. I'm probably making too much out of this.
Log in to reply
i just copy the statement, so it's more easy to compare.
"During an examination, 60 students had to answer 3 questions. After the examination, it's shown that for any two students, there is always at least 1 question which both students could solve."
Log in to reply
it deprnds on the original wording but 60/2 is dividing the 60 students into groups of 2. but any two students would be 60*59/2 (combinatorics: pick 2 out of 60).
so this is much more than 30.
regarding the 1 question that both could solve. the wording indicates that both had the same question correct.
and as i said: the total number of questions is not stated. it could be the 3 same questions for all 60 students, but it could be more depending on the conditions of the problem.
the problem like you described it sounds more like:
60 students are divided into groups of 2.
each group had to answer 3 questions. both students answered individually.
every student gave at least one correct answer.
Log in to reply
i was used to program in basic and c, but python is very nice.
i'm still on my way to understand how to use python-goodies like range and permutation.
but please feel free to ask questions regarding coding. it would be a pleasure for me to help you.
Log in to reply
Thank you. Long ago (30 years) I used Fortran, Watfive, Pascal and Pascal took the lead. I got into a lot of Finite Element modeling with programming but quickly canned programs came on the scene in the form of software. So, I drifted away from programming and relied on software. But I'm impressed with the flexibility Python offers and want to learn it. Been doing a little here and there but get lost in the goodies (permutations and other libraries). I'll be sure to take you up on that with questions as they arise. Thanks again!
Log in to reply
i dont know watfive. i will search that.
you said you'r a bridge engineer. that sounds very interesting.
Log in to reply
Log in to reply
fortran whatF iv was harder to find, they looked a bit like assembler code.
Log in to reply
Thank you! I didn't even consider that there could be more than 180 questions. Just assumed they were the same 3 questions.
Log in to reply
hm i assume 180 is the maximum if all student get different questions.
(there might be more but that should be mentioned like: ... had to answer 3 questions out of a set of questions.)
my first assumption was: all students get the same 3 questions.
i still assume this is the idea. but i have no idea what the question behind that setting is.
is this the original wording or is it just a draft for a challenge that you prepare?
Log in to reply
It's the actual wording of a problem in the challenges community I believe under logic. The writer intended for the groups of two to get the same question right. But I thought there could be different interpretations.
Log in to reply
just use this without the blanks: [ some text ] ( html )
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
"there is always at least 1 question which both students could solve."
--> implies that each student had at least 1 question solved.
--> if even one of them only scored 1/3, then that particular question must be solved by 59 others to make this claim true. We can see this in just a group of three, let ABC be the students and 123 the questions. Say q1 is the easiest one, so average students A and B could only manage that one. But even when brilliant C solved the other difficult two, but made careless mistake / ran out of time on q1, the claim will be invalid (A1, B1, C23).
--> if there are no 'easy' question which is scored by ALL the students, then all 60 must have solved AT LEAST 2 questions each.
Log in to reply
Thanks! I knew you'd make sense of this one. You are both a logician and mathematician.
Log in to reply
Thank you, Joe, but that compliment is too high for me. I am still struggling when confronted with questions under category group theory. Too much lines and nodes than I can handle. And sorry I didn't think deeper than taking it as the 60 are just the usual class of hs students answering the same 3 questions. Perhaps the assumptions brought along from Three Questions problem we just had around Xmas.
Log in to reply
Log in to reply
if you love math then you might like this question: Minimum value of equation - Exam Edition
i got scrambled so i used wolfram alpha to solve it.
Log in to reply
regarding 'beating a dead horse': hint: each char is coded as 2 digit number.
meaning: to waste effort on something when there is no chance of succeeding.
(beat a dead horse)
(i assume he wants to say that there is no benefit in discussing the different ways of solving the challenges. - in my opinion the expression does not fit here very well.)
in old times some riders did beat a horse to make it run faster, but if the horse is already done then this will have no effect.
Log in to reply
Expression means "We've discussed this so much and in so many ways but aren't making any progress." I value different approaches and don't understand why people think they have the ultimate solution. It's like asking, "who's better - the republican or democratic nominee? Obviously it depends on what you value. So, I'm advocating that all approaches that yield the correct answer are valuable. The lengthy one that experts find redundant appeals to the person who lacks that knowledge to solve. The programmer who has solved many cryptograms and is honing his programming skills is saving time but providing knowledge to those who don't know programming. Etc.
Log in to reply
my hope is that the discussion helps the critic to understand that there is a value in presenting different solutions (even coded ;-).
Log in to reply
i can tell you how the first coding was done, but i assume you want to try it by yourself first.
Log in to reply
Thanks, num IC! For the horse proverbs explanation and the hint, but still I'm getting no progress. I don't understand 2 parts there, one is the many 7 there (though your reply had an almost balanced quantity of 6 & 7), and the other is why there are abcd included there too.
Log in to reply
Log in to reply