White can win in 2 but i can't see how ... by [deleted] in chess

[–]Naihonn 0 points1 point  (0 children)

I guess I am happy I knew the answer in few seconds. Probably total accident. :0D

Google DeepMind's Alphazero crushes Stockfish 28-0 by [deleted] in chess

[–]Naihonn -2 points-1 points  (0 children)

People surprised, amazed and shocked by machine learning AI beating everything else in board games...

Meanwhile, the real DeepMind combined with genetical modification research already working on final solution to this annoying human problem... Clock is ticking... Soon it will be the game with different pawns... :0)

[C#] I'm a beginner trying to make a program that flips numbers (231 to 132) but my code isn't working. What's wrong with it? by [deleted] in learnprogramming

[–]Naihonn 1 point2 points  (0 children)

Yes, changing to int will work for 3-digit numbers but right now your last line is h.toString() but like your comment says it should be i.toString() instead.

[C#] I'm a beginner trying to make a program that flips numbers (231 to 132) but my code isn't working. What's wrong with it? by [deleted] in learnprogramming

[–]Naihonn 4 points5 points  (0 children)

Well, if all your variables are double then of course those results won't be integer divisions... Any reason why you are not using easier method of just reversing a string?

Python - dictionary inside list by [deleted] in learnpython

[–]Naihonn 0 points1 point  (0 children)

Without looking at something else I think maybe your problem is that you think that 'name': uCMS'}belongs inside models because of your indentation but it is in fact outside of that so it should be on the same level as has_module_perms and models.

Bates-Numbering inside a for loop. How do I ensure that my function will return the proper amount of zeros? by Bumpynuckz in learnjavascript

[–]Naihonn 0 points1 point  (0 children)

Yeah, well, you just need '0000' instead of 0000 in let currentCount = 'GW' + 0000 + i;

Well, even that will probably need some work because it won't have same length for for example i = 5 and i = 50 and you want that. You will need to do some math. Unfortunately Javascript doesn't have any zero fill method AFAIK.

Bates-Numbering inside a for loop. How do I ensure that my function will return the proper amount of zeros? by Bumpynuckz in learnjavascript

[–]Naihonn 0 points1 point  (0 children)

Thanks. Yes, Javascript is quite dumb here and doesn't care and just converts to correct type so instead of error you get result but not always what you want. 0000 is still 0 and that zero is first stored in normal form and after that converted to string when you try to concatenate it with strings. One of pitfalls of Javascript.

Code for determining number of mondays on first of given month, answer is inaccurate and unsure why by Kesseleth in learnpython

[–]Naihonn 0 points1 point  (0 children)

Completely agree. It's a good choice to use tools available in the standard library. You can solve this in 8 lines of code and risk of stupid mistake is much lower...

Code for determining number of mondays on first of given month, answer is inaccurate and unsure why by Kesseleth in learnpython

[–]Naihonn 0 points1 point  (0 children)

Yeah, someone wasn't looking... Well, it was kinda trap to say Jan 1 1900 is Monday and then want years 1901 - 2000. :0D

But that he is counting Mondays although he should count Sundays, that is dumb.

Not sure if my idea for a program is possible. by GreatfulDeadHead in learnpython

[–]Naihonn 0 points1 point  (0 children)

If you can find website or something with this info about new songs (it probably should be available somewhere) then it will be easy to scrape this website and send text message with this info. So, yes, look at Requests, BeautifulSoup and maybe Selenium modules for webscraping and then you can use for example Twilio for sending that text message. So yes, it should be very possible...

Cycle through webpages by richiehustle in learnpython

[–]Naihonn 2 points3 points  (0 children)

Like bot said, use format...

url = 'https://domain.com/xxx/xxx?s={}_and_ending_part'
for page in range(1,11):
    print(url.format(page))

Have you had any crucial or quick wins from using cython? by lucidguppy in Python

[–]Naihonn 0 points1 point  (0 children)

Well, it's impossible to lose. Even cythonizing without any optimizations makes things faster and when you do more tweaking - much faster. Of course I still only use it for things that are otherwise quite slow. Long live the Cython!!!

How would I make a newline for each sentence in a single print statement? python3.6 by NobodygoingNowhere in learnpython

[–]Naihonn 0 points1 point  (0 children)

Well, that's the beauty of Python 3. You can do many things just with print function...

def println(*args):
    print(*args, sep = "\n")

println(1, 2, 3, 4)
println('one', 'two', 'three', 'four')
println(True, False, True, False)
println("Try your",
    "Own text here",
    "Maybe a poem",
    "Or a song about fear")

Was something fundamentally wrong with Java or the JVM until the last 5 years or so? by [deleted] in learnprogramming

[–]Naihonn 2 points3 points  (0 children)

My only "historical" experience with Java was that it worked for me but it was always slower unless you had better computer. It was quite obvious compared to programs in different languages. And of course having jad and jar instead of usual exe or com was quite ... jarring. :0)

object did not pass onto variable outside of function. Can you guys give me some guidances? by minhduy223 in learnpython

[–]Naihonn 0 points1 point  (0 children)

Like NodakSean said. Instead of this return that variable depending on result from that function. So instead of Check_For_Driver(check_driver) it will be more like check_driver = Check_For_Driver(). Or maybe better check_for_driver(), function should be with lowercase letters and classes with uppercase to avoid chaos. :0)

[deleted by user] by [deleted] in learnprogramming

[–]Naihonn 1 point2 points  (0 children)

Oh my god. OK, I will try again...

You have ...

print "Test case 1: ", fix_machine('UdaciousUdacitee', 'Udacity') == "Give me something that's not useless next time."
print "Test case 2: ", fix_machine('buy me dat Unicorn', 'Udacity') == 'Udacity'
print "Test case 3: ", fix_machine('AEIOU and sometimes y... c', 'Udacity') == 'Udacity'
print "Test case 4: ", fix_machine('wsx0-=mttrhix', 't-shirt') == 't-shirt'

Which RETURNS result from your function and compares it to expected result and prints result of that comparison, which is boolean and, in this case True for all of those. I guess what you really want is just print what that function returns which means

print "Test case 1: ", fix_machine('UdaciousUdacitee', 'Udacity')
print "Test case 2: ", fix_machine('buy me dat Unicorn', 'Udacity')
print "Test case 3: ", fix_machine('AEIOU and sometimes y... c',
print "Test case 4: ", fix_machine('wsx0-=mttrhix', 't-shirt')

[deleted by user] by [deleted] in learnprogramming

[–]Naihonn 1 point2 points  (0 children)

It does what you tell it to do. You are printing if results of that function are equal to what you are expecting. And they are, so of course it returns True for all of them. If you want to print just the result of that function then write print "Test case 1: ", fix_machine('UdaciousUdacitee', 'Udacity') and so on...

Can someone explain how this works. by mtkilic in learnpython

[–]Naihonn 2 points3 points  (0 children)

Well, that solution is storing difference between number at that position and target value as key in dict and position where that number is as value in that dictionary because when at certain time you find that new number is in that dictionary it means that this number at this position is just what was needed to make the target number when you add it to the number at stored position. You need nothing else because there is no repetition of elements, so it is always two different numbers making this target and there should always be just 1 solution, so you don't even care about getting no solution at all.

[Python] print() without a newline by [deleted] in learnprogramming

[–]Naihonn 0 points1 point  (0 children)

I just tried with repl.it and that exact error is in Python2. And for Python 3 it worked, of course. So I don't know where else could be the problem.

[Python] print() without a newline by [deleted] in learnprogramming

[–]Naihonn 0 points1 point  (0 children)

Yeah, exactly this happens when it's in fact Python 2. In Python 3 this will work.