This wiki has very good and detailed infos: Latex guide 3.
and this too

Latex code begins with: \\(\)( and ends with: \)
to center it u can use: \[ and \]

short Latex-test 200\lfloor \approx 200\rfloor
3\boxed{3} \(\boxed{3}\) to write this as text use: \\(\)(\boxed{3}\\)

Note by Num Ic
1 month, 3 weeks ago

No vote yet
1 vote

  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:

  • 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.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

  • bulleted
  • list

1. numbered
2. list

  1. numbered
  2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1

paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
    # 4 spaces, and now they show
    # up as a code block.

    print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in \( ... \) or \[ ... \] to ensure proper formatting.
2 \times 3 2×3 2 \times 3
2^{34} 234 2^{34}
a_{i-1} ai1 a_{i-1}
\frac{2}{3} 23 \frac{2}{3}
\sqrt{2} 2 \sqrt{2}
\sum_{i=1}^3 i=13 \sum_{i=1}^3
\sin \theta sinθ \sin \theta
\boxed{123} 123 \boxed{123}

Comments

Sort by:

Top Newest

Nice & helpful discussion @num IC

SRIJAN Singh - 1 month, 3 weeks ago

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.

num IC - 1 month, 3 weeks ago

Log in to reply

I have deleted the chatbot discussion .Is there any problem or it is fine?

SRIJAN Singh - 1 month, 3 weeks ago

Log in to reply

Your welcome.

SRIJAN Singh - 1 month, 3 weeks ago

Log in to reply

OΔ   ΘΞΦΩ\large{\boldsymbol{ \Box \oplus} \nabla \boldsymbol{ \oslash \mathbb{O} \Diamond} \Delta \boldsymbol{ \ominus \otimes \odot ~~~ \ast \circ \triangle \Theta \Xi \Phi \Omega} }
OΔ   ΘΞΦΩ\large{ \Box \oplus \nabla \oslash \mathbb{O} \Diamond \Delta \ominus \otimes \odot ~~~ \ast \circ \triangle \Theta \Xi \Phi \Omega }

num IC - 1 month ago

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.

num IC - 1 month, 3 weeks ago

Log in to reply

Your huge welcome!

SRIJAN Singh - 1 month, 3 weeks ago

Log in to reply

andendswith:200 and ends with: 200 lol

Half pass3 - 1 month, 2 weeks ago

Log in to reply

Very simple latex

SRIJAN Singh - 1 month, 2 weeks ago

Log in to reply

;-) and can be copied (-;

num IC - 1 month, 2 weeks ago

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

NSCS 747 - 1 month ago

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. ;-)

num IC - 1 month ago

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

NSCS 747 - 1 month ago

Log in to reply

@Nscs 747 np. i saw that u posted a big empty reply to this oren. but i assume that this is not what u meant.
whatever, percy seems to defend this guy now, so can anyway not help you in this matter.

num IC - 1 month ago

Log in to reply

based on his last posts, i assume that he dont intend to stop annoying the community.
so you can try your surprise to stop him.

num IC - 1 month ago

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.

num IC - 1 month ago

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) :):)

Toska Pi - 1 month ago

Log in to reply

as i remember: the question was about "fixed CoM". you are welcome, i m glad that i could help

num IC - 1 month ago

Log in to reply

@Devbrat Dandotiya to write \(\boxed{3}\) u can use use: \\(\)(\boxed{3}\\)

num IC - 1 month ago

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.

Jonathan Eshetu - 4 weeks, 1 day ago

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.

num IC - 4 weeks, 1 day ago

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.

Jonathan Eshetu - 4 weeks, 1 day ago

Log in to reply

@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.

num IC - 4 weeks, 1 day ago

Log in to reply

@Bernd Fahrein kannst auch hier mit mir schreiben. i m not premium, so i cannot access daily challenges that are older than one week.

num IC - 4 weeks, 1 day ago

Log in to reply

? ? ? ?

NSCS 747 - 4 weeks, 1 day ago

Log in to reply

ty for this hint, so i know that everyone here gets a note, even when i (at) a specific member

num IC - 4 weeks, 1 day ago

Log in to reply

@Num Ic yes as we found during our experiments

NSCS 747 - 4 weeks ago

Log in to reply

@Bernd Fahrein please be aware, that everyone can see when u post a note. so please dont post private informations.

num IC - 4 weeks, 1 day ago

Log in to reply

@Bernd Fahrein
you can insert a picture by using: ![description](img url)
here is a link to a how to page
here too
you need the pic to be stored online, so you can insert the link ;-)
(i prefer to use imgur.com)
here is the pic that we have talked about (slightly modified ;-): 3 elephants mirrored 3 elephants mirrored

num IC - 1 week, 6 days ago

Log in to reply

Heyo, someone give me a problem to solve with python.

Jonathan Eshetu - 4 weeks ago

Log in to reply

what about the daily challenges?

num IC - 4 weeks ago

Log in to reply

I've already completed most of the ones that you could solve with programming...but thanks for the suggestion.

Jonathan Eshetu - 4 weeks ago

Log in to reply

@Jonathan Eshetu for starters: find the greatest common divisor for two numbers, without using the python gcd-function

num IC - 4 weeks ago

Log in to reply

@Num Ic

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
print("Pick two numbers to find the greatest common divisor")
a = input()
b = input()
cd = 0
a = int(a)
b = int(b)
if a > b:
    for i in range(1, b+1):
        if a%i == 0 and b%i == 0:
            if i > cd:
                cd = i
else:
    for i in range(1, a+1):
        if a%i == 0 and b%i == 0:
            if i > cd:
                cd = i

print(cd)

Jonathan Eshetu - 4 weeks ago

Log in to reply

@Jonathan Eshetu Is that good?

Jonathan Eshetu - 4 weeks ago

Log in to reply

@Jonathan Eshetu overal nice. some improvements: a = int(input())

i = min(a,b)
while a%i !=0 or b%i !=0:
    i -= 1
cd = i
print(cd)

num IC - 4 weeks ago

Log in to reply

@Num Ic Wow, I didn't think of that approach, I'm so used to for loops. I feel so stupid for not thinking of using min() too.

I'm assuming you meant b%i by the way.

Jonathan Eshetu - 4 weeks ago

Log in to reply

@Jonathan Eshetu ty i corrected it.
its not my intention to make u feel stupid.

num IC - 3 weeks, 6 days ago

Log in to reply

@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?

num IC - 4 weeks ago

Log in to reply

@Num Ic Sorry, I lost you at euklid.

What does euklid and recursive mean?

Jonathan Eshetu - 4 weeks ago

Log in to reply

@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 - 3 weeks, 6 days ago

Log in to reply

@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.

Jonathan Eshetu - 3 weeks, 6 days ago

Log in to reply

@Num Ic

1
2
3
4
5
6
7
def euclidGCD(a, b):
    if a == 0:
        print(b)
    elif b == 0:
        print(a)
    else:
       euclidGCD(b, a%b)

Jonathan Eshetu - 3 weeks, 6 days ago

Log in to reply

@Jonathan Eshetu one change:

def euclidGCD(a, b):
    if a == 0:
        return(b)
    elif b == 0:
        return(a)
    else:
       return(euclidGCD(b, a%b))

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

num IC - 3 weeks, 6 days ago

Log in to reply

@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 - 3 weeks, 6 days ago

Log in to reply

@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))

num IC - 3 weeks, 6 days ago

Log in to reply

@Num Ic Ohhh, that's my mistake. I didn't add the print, I just called the function.

Jonathan Eshetu - 3 weeks, 6 days ago

Log in to reply

@Jonathan Eshetu yeah, print is mainly for checking.
to use it, it would be like:
g = euclidGCD(8, 4)

num IC - 3 weeks, 6 days ago

Log in to reply

@Num Ic Yeah, that makes sense. To be fair though, in an actual program you could just use the actual gcd function.

Jonathan Eshetu - 3 weeks, 6 days ago

Log in to reply

@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.

num IC - 3 weeks, 6 days ago

Log in to reply

@Num Ic Ah, I've seen some of his solutions. They're very hard to understand, but I try.

Jonathan Eshetu - 3 weeks, 6 days ago

Log in to reply

@Jonathan Eshetu in your text, the return is in a little box. how did you do that?

num IC - 3 weeks, 6 days ago

Log in to reply

@Num Ic just put three tick marks ` before and after. like this

Jonathan Eshetu - 3 weeks, 6 days ago

Log in to reply

@Jonathan Eshetu ok thank you, i didnt know that

num IC - 3 weeks, 6 days ago

Log in to reply

@Num Ic You're most certainly welcome. I found it out on accident :)

Jonathan Eshetu - 3 weeks, 6 days ago

Log in to reply

@Num Ic Thank you though!

Jonathan Eshetu - 3 weeks, 6 days ago

Log in to reply

@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 - 3 weeks, 6 days ago

Log in to reply

@Num Ic It does. You can learn a lot by reading others solutions on brilliant, one of my favorite features.

Jonathan Eshetu - 3 weeks, 6 days ago

Log in to reply

@Jonathan Eshetu i did the free course on this page: coursera.org
it is in russian, but i translated the pages (i ignored the videos)

num IC - 4 weeks ago

Log in to reply

@Num Ic I'll check that out, thanks!

I've just been using Brilliant's python course and self-study, but that seems better.

Jonathan Eshetu - 4 weeks ago

Log in to reply

@Jonathan Eshetu we used different conditions. can you explain what the difference between those conditions is?

num IC - 3 weeks, 6 days ago

Log in to reply

@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 - 3 weeks, 6 days ago

Log in to reply

@Jonathan Eshetu very good. you got it and you also explained it very well.

num IC - 3 weeks, 6 days ago

Log in to reply

@Num Ic Thanks! These mini-exercizes/explanations are helping a lot.

Jonathan Eshetu - 3 weeks, 6 days ago

Log in to reply

@Jonathan Eshetu you can also use "python" in the search bar. some users post python quests.
i just found this: Using Recursion (Python loop) and this: Break the Code

num IC - 3 weeks, 6 days ago

Log in to reply

@Num Ic The first problem I got pretty easily, but I'm still confused over the second...

Could you please explain, if you got it? I'm just scratching my head right now...

Jonathan Eshetu - 3 weeks, 6 days ago

Log in to reply

@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?

num IC - 3 weeks, 5 days ago

Log in to reply

@Num Ic Wait...but by that logic, don't all values not work?

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.

Jonathan Eshetu - 3 weeks, 5 days ago

Log in to reply

@Jonathan Eshetu ;-) it was no "task" to check that course. just a proposal.

num IC - 3 weeks, 5 days ago

Log in to reply

@Num Ic :) But still, wouldn't all values be correct for the problem?

Jonathan Eshetu - 3 weeks, 5 days ago

Log in to reply

@Jonathan Eshetu you can just create the code for all 3 _ values and then check it for 1 to 100 as input.

num IC - 3 weeks, 5 days ago

Log in to reply

@Num Ic I'll get back to you in the morning on this, because my head is hurting a little too much right now. Good night!

Jonathan Eshetu - 3 weeks, 5 days ago

Log in to reply

@Jonathan Eshetu np. take care

num IC - 3 weeks, 5 days ago

Log in to reply

@Num Ic Ok, so I think I get it now.

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 - 3 weeks, 5 days ago

Log in to reply

@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 - 3 weeks, 5 days ago

Log in to reply

@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 - 3 weeks, 5 days ago

Log in to reply

@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 - 3 weeks, 5 days ago

Log in to reply

@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 - 3 weeks, 5 days ago

Log in to reply

@Jonathan Eshetu thats a great hint ty

num IC - 3 weeks, 5 days ago

Log in to reply

@Num Ic I also didn't see the websites carsten proposed. Could you please send a link?

Jonathan Eshetu - 3 weeks, 5 days ago

Log in to reply

@Jonathan Eshetu @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.

Jonathan Eshetu - 3 weeks, 4 days ago

Log in to reply

@Num Ic Sorry that it's cramped, I can't do line breaks for some reason. You don't need to read it, I just think I understand now.

Jonathan Eshetu - 3 weeks, 5 days ago

Log in to reply

@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)

num IC - 3 weeks, 5 days ago

Log in to reply

@Jonathan Eshetu you can just try this ;-) :

def rec(n):
    print(n)
    if n <= 0:
        return 0
    return 3 + rec(rec(n - 2))

N = 5
for i in range(1, N):
    print(i, rec(i))

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.

num IC - 3 weeks, 5 days ago

Log in to reply

@Num Ic Hm, what do you mean by recursion depth? Sorry if that's a stupid question...

Jonathan Eshetu - 3 weeks, 5 days ago

Log in to reply

@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)

-> recursion depth 4

num IC - 3 weeks, 5 days ago

Log in to reply

@Num Ic Ohhh, ok. That makes a ton more sense now. I'll do that program tmrw morning. :)

Jonathan Eshetu - 3 weeks, 5 days ago

Log in to reply

@Jonathan Eshetu can you solve this with python?
maybe this is better

num IC - 3 weeks, 5 days ago

Log in to reply

@Num Ic Well uhh....I already solved it intuition wise accidentally....

Jonathan Eshetu - 3 weeks, 5 days ago

Log in to reply

@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 - 3 weeks, 5 days ago

Log in to reply

@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)

num IC - 3 weeks, 5 days ago

Log in to reply

I need to test my programming skills.

Jonathan Eshetu - 4 weeks ago

Log in to reply

i can sure propose something, but i would prefer if people use "please" when they ask for something.

num IC - 4 weeks ago

Log in to reply

Sorry about that.

I was a bit....impatient when I wrote that. Completely my fault. Could you please?

Jonathan Eshetu - 4 weeks ago

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?

num IC - 3 weeks, 6 days ago

Log in to reply

Hi, I have used Keynote. I grouped the lines and then rotated. Refer this if you have any more questions

Mahdi Raza - 3 weeks, 6 days ago

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.

num IC - 3 weeks, 6 days ago

Log in to reply

@Num Ic Thank you, would like to see your animations too...

Mahdi Raza - 3 weeks, 6 days ago

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?

1
2
3
4
5
6
7
8
9
def factorial(n):
    nFac = 1
    for i in range(1, n+1):
        nFac *= i
    return nFac
# 5 => 120
# 7 => 5040
# 10 => 3628800
# 300 => 306057512216440636035370461297268629388588804173576999416776741259476533176716867465515291422477573349939147888701726368864263907759003154226842927906974559841225476930271954604008012215776252176854255965356903506788725264321896264299365204576448830388909753943489625436053225980776521270822437639449120128678675368305712293681943649956460498166450227716500185176546469340112226034729724066333258583506870150169794168850353752137554910289126407157154830282284937952636580145235233156936482233436799254594095276820608062232812387383880817049600000000000000000000000000000000000000000000000000000000000000000000000000 ;)

Jonathan Eshetu - 3 weeks, 5 days ago

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.

num IC - 3 weeks, 4 days ago

Log in to reply

Here's the program I used for the 10 digit problem:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Input
import itertools
import math
nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in itertools.permutations(nums):
    if i[0] == 0:
        continue
    i = int(''.join(map(str, i)))
    if math.sqrt(i).is_integer():
        print(i)
        break

# Output
1026753849

Jonathan Eshetu - 3 weeks, 4 days ago

Log in to reply

@Jonathan Eshetu nice. i knew that was too easy for you, since you already used permutations. ;-)

num IC - 3 weeks, 4 days ago

Log in to reply

@Num Ic Thanks :D

Jonathan Eshetu - 3 weeks, 4 days ago

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...

Jonathan Eshetu - 3 weeks, 4 days ago

Log in to reply

@Jonathan Eshetu in theory it is infinite. but that would create an endless loop. there is a limit.

num IC - 3 weeks, 4 days ago

Log in to reply

@Num Ic Ok, my mind is blown.

For starters, I edited the function a little bit, so that it measures how many times the function is called.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Input
a = [] # This is an array so we can print the values if needed
def rec(n):
    a.append(n)
    if n <= 0:
        return 0

    return 3 + rec(rec(n - 3))

for x in range(1, 50):
    print(x, "-", rec(x), len(a))
    a.clear()

# Output
1 - 3 3
2 - 3 3
3 - 3 3
4 - 6 7
5 - 6 7
6 - 6 7
7 - 9 15
8 - 9 15
9 - 9 15
10 - 12 31
11 - 12 31
12 - 12 31
13 - 15 63
14 - 15 63
15 - 15 63
16 - 18 127
17 - 18 127
18 - 18 127
19 - 21 255
20 - 21 255
21 - 21 255
22 - 24 511
23 - 24 511
24 - 24 511
25 - 27 1023
26 - 27 1023
27 - 27 1023
28 - 30 2047
29 - 30 2047
30 - 30 2047
31 - 33 4095
32 - 33 4095
33 - 33 4095
34 - 36 8191
35 - 36 8191
36 - 36 8191
37 - 39 16383
38 - 39 16383
39 - 39 16383
40 - 42 32767
41 - 42 32767
42 - 42 32767
43 - 45 65535
44 - 45 65535
45 - 45 65535
46 - 48 131071
47 - 48 131071
48 - 48 131071
49 - 51 262143

Jonathan Eshetu - 3 weeks, 4 days ago

Log in to reply

@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 - 3 weeks, 4 days ago

Log in to reply

@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.

num IC - 3 weeks, 4 days ago

Log in to reply

@Num Ic Oh, you want me to create a simple function and then test the recursion depth with another program?

Jonathan Eshetu - 3 weeks, 4 days ago

Log in to reply

@Jonathan Eshetu hm, no. just a small code, that continuously calls itself and then you run it and check the error message

num IC - 3 weeks, 4 days ago

Log in to reply

@Num Ic

1
2
3
4
5
6
7
8
9
a = 0
def letsBreakIDLE():
    global a
    a += 1
    print(a)
    letsBreakIDLE()

letsBreakIDLE()
# Output stops at 1012

Jonathan Eshetu - 3 weeks, 3 days ago

Log in to reply

@Jonathan Eshetu nice. mine stopped at 997 when i tried this in brilliant:

def rec(n):
    print(n)
    rec(n+1)

rec(1)

num IC - 3 weeks, 3 days ago

Log in to reply

@Num Ic Even in IDLE, the function starts to slow down at around 60.

Jonathan Eshetu - 3 weeks, 4 days ago

Log in to reply

@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 - 3 weeks, 4 days ago

Log in to reply

@Num Ic Sorry about this, I had my hands full of schoolwork last night.

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

Jonathan Eshetu - 3 weeks, 3 days ago

Log in to reply

@Jonathan Eshetu ok. i have tried none of them.
do you reccomend them? do you have questions?

num IC - 3 weeks, 3 days ago

Log in to reply

@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.

Jonathan Eshetu - 3 weeks, 3 days ago

Log in to reply

@Jonathan Eshetu t="hello"
print(t[:2]) what did u use to get the first 2 letters?

num IC - 3 weeks, 3 days ago

Log in to reply

@Num Ic That's the thing, I didn't know what to use. Thank you!

Jonathan Eshetu - 3 weeks, 3 days ago

Log in to reply

@Num Ic I thought [num:num] only worked on arrays.

Jonathan Eshetu - 3 weeks, 3 days ago

Log in to reply

@Jonathan Eshetu this works in brilliant:

t="hello"
print(t[:2],"...",t[:2],"...",t, sep='')

a string is an array, just filled with chars

num IC - 3 weeks, 3 days ago

Log in to reply

@Num Ic Ah, I didn't think about it that way. Completely forgot about [:] and sep. Thanks!

Jonathan Eshetu - 3 weeks, 3 days ago

Log in to reply

@Jonathan Eshetu yw. i had to google sep bcs i usually dont use it. its also possible to use a formated print, but i dont know how that works.

num IC - 3 weeks, 3 days ago

Log in to reply

this is a good idea to train using strings and dictionaries:
https://brilliant.org/problems/you-ninja-name/

num IC - 3 weeks, 1 day ago

Log in to reply

sorry this is so late.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def ninjaToEnglish(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('~')
    for i in phrase:
        for key, value in ninjaDict.items():
            if i == value:
                engText.append(key)
    engText = ''.join(engText)
    return engText

print(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 - 2 weeks, 6 days ago

Log in to reply

@Jonathan Eshetu nice

num IC - 2 weeks, 6 days ago

Log in to reply

@Num Ic thx

Jonathan Eshetu - 2 weeks, 6 days ago

Log in to reply

@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.

num IC - 2 weeks, 6 days ago

Log in to reply

@Num Ic changes it from ['e', 'x', 'a', 'm', 'p', 'l', 'e'] to 'example'

Jonathan Eshetu - 2 weeks, 6 days ago

Log in to reply

@Jonathan Eshetu cool trick. ty

num IC - 2 weeks, 6 days ago

Log in to reply

@Num Ic welcome.

Jonathan Eshetu - 2 weeks, 6 days ago

Log in to reply

@Jonathan Eshetu i would have used:
engText = ""
and then:
engText += key

but good to know how to convert an array into a string.

num IC - 2 weeks, 6 days ago

Log in to reply

@Num Ic true, i didn't think of that.

Jonathan Eshetu - 2 weeks, 6 days ago

Log in to reply

@Num Ic I had to do a bit of searching up, since I wasn't familiar with dictionaries.

Jonathan Eshetu - 2 weeks, 6 days ago

Log in to reply

@Jonathan Eshetu yeah thats where i struggled with the online course: i had no experience with python dictionaries.

num IC - 2 weeks, 6 days ago

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.

1
2
def perfectNumberCheck(n):
    print(n, "\n", "divisors:", ' '.join(map(str, [i for i in range(1, n) if n%i == 0] + [n])), "\n", "sum of divisors (aside from itself):", sum([i for i in range(1, n) if n%i == 0]), "\n", "Perfect number:", "True" if sum([i for i in range(1, n) if n%i == 0]) == n else "False", "\n", "\n")

Try it out!

Jonathan Eshetu - 2 weeks, 2 days ago

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 ;-)

num IC - 2 weeks, 2 days ago

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?

Jonathan Eshetu - 2 weeks, 2 days ago

Log in to reply

@Jonathan Eshetu Here it is a bit..neater, because I assigned the divisors array so I wouldn't have to spam it.

1
def perfectNumberCheck(n): divisors = [i for i in range(1, n) if n%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" if sum(divisors) - n == n else "False", "\n")

Jonathan Eshetu - 2 weeks, 2 days ago

Log in to reply

@Jonathan Eshetu this is great !! i wanted to say that repeating the same is not efficient, but this 2nd thing is very good

num IC - 2 weeks, 2 days ago

Log in to reply

@Num Ic Thank you! I appreciate it :)

Jonathan Eshetu - 2 weeks, 2 days ago

Log in to reply

@Num Ic Hey Num Ic, could you please give me a coding challenge? It can be on brilliant, or anything really. Thanks!

Jonathan Eshetu - 2 weeks, 1 day ago

Log in to reply

@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.

num IC - 2 weeks, 1 day ago

Log in to reply

@Num Ic wait, there's no difference between "n cows" and "n cows"?

Jonathan Eshetu - 2 weeks, 1 day ago

Log in to reply

@Num Ic oh wait nvm.

Jonathan Eshetu - 2 weeks, 1 day ago

Log in to reply

@Num Ic it translated to english for some reason.

Jonathan Eshetu - 2 weeks, 1 day ago

Log in to reply

@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 ;-(

num IC - 2 weeks ago

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)

num IC - 2 weeks, 1 day ago

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.

num IC - 1 week, 6 days ago

Log in to reply

Ok, you can post it here. Thanks :)

Percy Jackson - 1 week, 6 days ago

Log in to reply

Thanks :)

Percy Jackson - 1 week, 6 days ago

Log in to reply

javascript:

var img1Load, img2Load;
var total = '';
var customColor, customWeight, customSpeed;
var linecolor, weight, speed;

function preload() {
  img1Load = loadImage('PicCandy.JPG');
  img2Load = loadImage('Colour.png');
}

function restar() {
  image(img1Load, 220, 200, 440, 400);
  lastFrame = frameCount;
  waitFrame = true;
  state = 0;
}

function setup() {
  createCanvas(650, 450);
  background('white');
  imageMode(CENTER);
  image(img1Load, 220, 200, 440, 400);
  image(img2Load, 535, 140, 160, 20);

  customColor = createSlider(0, 360, 0);
  customWeight = createSlider(2, 15, 5);
  customSpeed = createSlider(1, 120, 60);
  cButton = createButton("Restart");

  customColor.position(450, 100);
  customWeight.position(450, 210);
  customSpeed.position(450, 300);
  cButton.position(500, 380);
  cButton.mousePressed(restar);

  lastFrame = 0;
  waitFrame = true;
  state = 0;

  textAlign(CENTER);
  strokeWeight(5);
  noStroke();
  textSize(19);
  text('Path Color', 530, 100);
  text('Path Width', 535, 210);
  text('Animation Speed', 535, 300);

  textSize(15);
  text('Thin', 455, 250);
  text('Thick', 605, 250);
  text('Low', 605, 340);
  text('High', 455, 340);
}

function draw() {
  //frameCount = 0;

  linecolor = customColor.value();
  weight = customWeight.value();
  speed = customSpeed.value();

  textAlign(CENTER);
  strokeWeight(weight);
  noStroke();
  textSize(19);
  rect(0, 400, 500, 50);
  text('Total : ' + total, 250, 430);
  colorMode(HSB);
  stroke(360 - linecolor, 100, 100);
  colorMode(RGB);

  if (waitFrame) {
    if (frameCount >= lastFrame + speed) {
      waitFrame = false;
      lastFrame = frameCount;
    }
  } else {

    if (state <= 15) {
      state = state + 1;
      waitFrame = true;
    }

    if (state === 1) {
      line(200, 268, 358, 151);
      total = '10';
    }

    if (state === 2) {
      line(358, 151, 358, 268);
      total = '10 + 9';
    }

    if (state === 3) {
      line(358, 268, 200, 268);
      total = '10 + 9 + 7';
    }

    if (state === 4) {
      line(200, 268, 40, 385);
      total = '10 + 9 + 7 + 4';
    }

    if (state === 5) {
      line(40, 385, 40, 268);
      total = '10 + 9 + 7 + 4 + 4';
    }

    if (state === 6) {
      line(40, 268, 200, 268);
      total = '10 + 9 + 7 + 4 + 4 + 6';
    }

    if (state === 7) {
      line(200, 268, 200, 151);
      total = '10 + 9 + 7 + 4 + 4 + 6 + 4';
    }

    if (state === 8) {
      line(200, 151, 358, 151);
      total = '10 + 9 + 7 + 4 + 4 + 6 + 4 + 8';
    }

    if (state === 9) {
      line(358, 151, 358, 36);
      total = '10 + 9 + 7 + 4 + 4 + 6 + 4 + 8 + 6';
    }

    if (state === 10) {
      line(358, 36, 40, 36);
      total = '10 + 9 + 7 + 4 + 4 + 6 + 4 + 8 + 6 + 7';
    }

    if (state === 11) {
      line(40, 36, 40, 151);
      total = '10 + 9 + 7 + 4 + 4 + 6 + 4 + 8 + 6 + 7 + 5';
    }

    if (state === 12) {
      line(40, 151, 200, 151);
      total = '10 + 9 + 7 + 4 + 4 + 6 + 4 + 8 + 6 + 7 + 5 + 7';
    }

    if (state === 13) {
      line(200, 151, 358, 36);
      total = '10 + 9 + 7 + 4 + 4 + 6 + 4 + 8 + 6 + 7 + 5 + 7 + 7';
    }

    if (state === 14) {
      total = '84';
    }

  }

}

num IC - 1 week, 6 days ago

Log in to reply

@Num Ic Thanks for the code, it works :)

Percy Jackson - 1 week, 6 days ago

Log in to reply

I wish you success with your exams.

num IC - 1 week, 6 days ago

Log in to reply

@Num Ic Thanks :)

Percy Jackson - 1 week, 6 days ago

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

num IC - 2 weeks, 1 day ago

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!

Jonathan Eshetu - 1 week, 3 days ago

Log in to reply

×

Problem Loading...

Note Loading...

Set Loading...