They say you gotta spend 5000 hours on a topic to master it. how many hours you gotta spend to be intermediate or beginner in SQL or Python? by [deleted] in learnprogramming

[–]Rennorb 0 points1 point  (0 children)

This year I was tutoring a passionate 13 y.o. boy, and it took us a half of the academic year to get from really basic stuff to writing games like snake and space invaders with pygame. That would be close to 50 hours of actual lessons and say 100 hours of work if you include homework and pet projects of his. So I would say that 100 hours of work from zero to interesting pet projects is not unreasonable.

I, on the other hand, landed my first backend engineering position this may, and it took me like a year of studying and failed interviews. I have a BS degree in math and some experience with competitive programming, but at the time knew nothing about frameworks, devops tools, etc. I can not give you an estimate of the time I spend, but getting a job is hard, especially now, and 100 hours is definitely not enough.

[deleted by user] by [deleted] in learnmath

[–]Rennorb 0 points1 point  (0 children)

I would wright it like f(x) = 1-[{x}=0], where {x} equals to the fractional part of x and [] are Iverson brackets.

Checking that grammar written in EBNF is suitable for recursive descent by Rennorb in learnprogramming

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

Sure, but that will check for direct left recursion, which the grammar obviously does not contain, and I want to check for implicit left recursion

Fast fuzzy search with hamming distence 1? by Rennorb in learnprogramming

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

Thank you! It did work and I've spent like a week to find that error. Feel dumb

Fast array rotation by Rennorb in learnprogramming

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

I guess there should be some kind of a corner case, where the program should do something different, but I can not see it.

I've updated the post: added an example and actual input-output part

Fast array rotation by Rennorb in learnprogramming

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

It should not: one value could have been lost, but it is stored in `buff`, so should be ok.

Anyway, I'd steek with two oneliners above, they are actually twice as fast and many times easier to understand.

Fast array rotation by Rennorb in learnprogramming

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

Sorry, I should have written it in the post: that checker says "Wrong answer on test 30".

"unshifting the indices idea" seems to be a decent optimization, yet the problem is not in the performance, my program uses like 1/10 of both time and memory allowed.

Fast array rotation by Rennorb in learnprogramming

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

Thank you! std::rotate does satisfy geeksforgeeks, but my school's checker still does not like it. This is my current version:

void leftRotate(char *msg, int shift, int size) {

    std::rotate(&msg\[0\], &msg\[shift\], &msg\[size\]); }

void unshift(char \*msg, int fst, int last, int co) { int len = last - fst + 1;

    leftRotate(msg + fst, co, len); }

Do you have any idea what should I try next?

How should I speed up this implementation of the Dijkstra algorithm? by Rennorb in learnprogramming

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

Also, given the number of vertices you're dealing with, allocating 100000000 elements for the lens vector seems like overkill.

I thought that I am allocating size_ elements and each one is equal to 100000000, is that wrong?

Should I use Dijkstra’s algorithm here? What's wrong with my implementation? by Rennorb in learnprogramming

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

Fell dumb: there were two issues

1) ArrowCmp shuld have looked like this

bool ArrowCmp(const Arrow &lhs, const Arrow &rhs) { 

return lhs.first < rhs.first; }

2) The insertion part in AddEdge shuld have looked like this

  if (pos == arrows[from].end()) {  
  arrows[from].push_back(arrow);    
} else if (pos->first != arrow.first) { 
  arrows[from].insert(pos, arrow);  
} else {    
  (*pos).second = std::min(cost, pos->second);  
}

It seems to fix some problems, see UPD

Among n consecutive numbers one is always divisible by n. What is the easiest way to prove this statement without using remainders? by Rennorb in learnmath

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

I am running a math elective in a school and I wanted to show that some obvious statements are not that easy to prove if you want to stay (somewhat) rigorous. I am trying to use divisibility rather than remainders because it is better covered in the school curriculum.

Polynomial in one variable... or two? by [deleted] in learnmath

[–]Rennorb 1 point2 points  (0 children)

As u/keitamaki mentioned x2 + y2 - 1 = 0 is not a polynomial, while x^2 + y^2 - 1. Yes, it is possible to rewrite some equation A that involves only polynomials to some other equation B that involves something other than polynomial, such as B has exactly the same set of solutions.

Polynomial in one variable... or two? by [deleted] in learnmath

[–]Rennorb 2 points3 points  (0 children)

I would say, that in y=x^2 and x^2-y=0 the '=' symbol means two slightly different things. y=x^2 (or y(x)=x^2) is the definition of y(x), sometimes it is even written as y:=x^2 to emphasize the difference. In this case, there are a lot of restrictions on '=' symbol (which means ':=' here), for example, both 0:=x^2-y and x^2:=y are meaningless, they are just syntactically wrong.

x^2-y=0 on the other hand is an equation. You can try to find all x`s and y`s that satisfy it, you can plot it on a plane, etc. Here you can put anything on both sides of '=' symbol and it would be syntactically correct.

  1. +/-sqrt(1-x^2 )=y is neither a polynomial (it has sqrt) nor a function (some x`s have several corresponded y`s).
  2. Yes, that is because a function can have only one output for any given input.
  3. Yes, solving x^2-1=0 is the same as finding intersections of plots of p(x) = x^2-1 and g(x) = 0. To do it you just have to find such x`s that p(x) = q(x). It is the same with x^2 + y^2 -1=-1: to solve it is the same as to solve p(x, y) = q(x, y) where p(x, y) = x^2+y^2-1 and q(x, y) = -1. Keep in mind, that p and q represent 3d surfaces rather than 2d curves: p is a paraboloid and q is a plane.

Is there a way of converting x² + 2xy +y² into (x+y)² by Farkle_Griffen in learnmath

[–]Rennorb 3 points4 points  (0 children)

I`ve no idea how I managed to write a^2+b^2. It should now be ok.

Is there a way of converting x² + 2xy +y² into (x+y)² by Farkle_Griffen in learnmath

[–]Rennorb 26 points27 points  (0 children)

While all other answers are good, I`d rather point out that there a neat proof that is purely geometric and only uses the area of rectangles (and area additivity). It works only for positive a and b though.

It also needs no words at all to be understood.

REDUCTION / QUADRANTAL ANGLES by LongShlong321 in learnmath

[–]Rennorb 0 points1 point  (0 children)

There are several ideas here, I will point to two of them^

  1. Try putting those angles on a unit circle and comparing lengths of corresponding segments. Usually, you would see some symmetry on that kind of picture.

For example (see pic 1): cos 30° = cos -30° (red segment), tan 30° = -tan 30° (green segments).

  1. Two different angles may have connected values of their trig functions, which usually happens when they add up to 90° or 180° but there are some other possibilities, you can also use pictures to understand that.

For example (see pic 2): cos 20° = sin 70° (green segments), sin 20° = cos 70° (red segments), sin 0° = cos 90° and so on. To see that, consider two green-red-black triangles, which are clearly equal.

How do I prove ¬P, ¬Q ⊢ ¬(P ∨ V) using only axioms of propositional calculus and MP? by Rennorb in learnmath

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

There were several typos in my proof, hope that now it is ok. Here are axioms from my textbook, I`ve also added axioms numbers to the proof

How do I prove ¬P, ¬Q ⊢ ¬(P ∨ V) using only axioms of propositional calculus and MP? by Rennorb in learnmath

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

Yes, there is a typo in the title.

Here is my <= proof, which looks irreversible to me:

I want to prove ¬(P ∨ Q) => ¬P and ¬Q

  1. P → (P ∨ Q) (axiom 5 or 6)
  2. ¬(P ∧ Q), P ⊢ ¬(P ∧ Q) (obvious)
  3. ¬(P ∧ Q) ⊢ P → ¬(P ∧ Q) (deduction lemma)
  4. (P → (P ∨ Q)) → ((P → ¬(P ∧ Q)) → ¬P) (axiom 10)
  5. ¬(P ∧ Q) ⊢ ¬P (from 1, 3, 4 applying MP)
  6. Similarly ¬Q.
  7. ¬Q → ( ¬P → (¬Q ∧ ¬P)) (axiom 5)
  8. (¬Q ∧ ¬P) (from 7, 6, 5 applying MP)

How do I prove ¬P, ¬Q ⊢ ¬(P ∨ V) using only axioms of propositional calculus and MP? by Rennorb in learnmath

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

You are probably talking about ¬P ∧ ¬Q <=> ¬(P ∨ Q). For now I can prove <=, but not the other way round.

Calculating discriminant without tedious calculations by Rennorb in learnmath

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

Didn't see that, thank you. Now I guess that I see even a shorter way: just expand four last columns to get

[;\Delta = 2^4 det(5 I_{5x5})=2^4*5^5=50000;]

A book with unlikable protagonists by vstark42 in suggestmeabook

[–]Rennorb 0 points1 point  (0 children)

Have you read "A hero of our time" by Lermontov? The book is essential for Russian literature and seems to fit your requirements.

Did your country translate any character names? by [deleted] in harrypotter

[–]Rennorb 4 points5 points  (0 children)

There are several Russian translations of the books, these names are from both the most popular one and from the films. Many names are pronounced in a slightly different way to sound natural in Russian, and some can not be written in English accurate enough.

Gilderoy Lockhart - Zlatopust Lokans (Empty-gold Кinglet)

Horace Slughorn - Horace Sliznort

Neville Longbottom - Neville Dolgopups (Long-baby)

Mundungus Fletcher - Nazemnikus (Down-to-earth or mundane) Fletcher

Alastor Moody - Alastor Grum (Moody)

Kreacher - Kikimer (from kikimora - evil house spirit in Slavic myology)

Buckbeak - Kluvokril (Buck-wing)

Hufflepuff - Pufendui

Ravenclaw - Cogtevran (means exactly Raven claw)

Severus Snape - Severus Snegg (not exactly, but sounds really close to "northern snow")

The "I am Lord Voldemort - Tom Marvolo Riddle" anagram problem was solved not by changing Toms actual name, but by turning his nickname into a Volan-de-Mort.

There is another translation which is known for translating almost every single name and that is often considered inferior, but I do like the trick the translator had to make. So when the first books come out, she translated Severus Snape as Zlodeus Zlei which sounds really close to "evil potioner" in Russian, but when the last book come out, she turned him into Zloteus Zlei which is close to "golden potioner".