• Breaking News

    Sunday, May 5, 2019

    Python3: LeetCode vs IDEs Ask Programming

    Python3: LeetCode vs IDEs Ask Programming


    Python3: LeetCode vs IDEs

    Posted: 05 May 2019 06:01 PM PDT

    I have never really extensively used Python as my programming language, but whenever I have, I have used Jupyter or Spyder for Python3.

    I have an interview next week in Python so I thought I'd start practicing on LeetCode and Python3 on there seems really different. i.e. function definition:

    def kthSmallest(self, root: TreeNode, k: int) 

    In Jupyter, I'd just enter:

    def kthSmallest(TreeNode root, int k) 

    But this apparently is NOT Python3 according to LeetCode. I am sure I was using Python3 on other IDEs. What is going on?

    submitted by /u/notyourdaddy
    [link] [comments]

    How do I store anchor text onclick to a php variable?

    Posted: 05 May 2019 03:39 PM PDT

    Does anyone know how I can achieve what I want?

    I'm making a book catalog, and I want to know if it's possible to store the book name during the onclick even onto a php variable in which I can access in a next page (I want to use $_SESSION[''])

    In essence I wish to get the text within the anchor tags, when i click on the text, it supposed to store in in a php variable Which I can use

    submitted by /u/Nobrainzone
    [link] [comments]

    Running waifu2x-caffe-ubuntu on vast.ai

    Posted: 05 May 2019 08:59 PM PDT

    I'm pretty sure this is not the right place to ask, any suggestions would be great. So basically I am trying to run this image-upscaling tool called waifu2x-caffe, which is originally built for windows. However, the original creator of waifu2x created waifu2x-caffe for ubuntu found here.

    The creator included an install instruction readme, which says "I tested on Ubuntu16.04 + CUDA8.0 + CuDNN 5.0 + GTX 1080".

    I don't have an nvidia graphics card so I am trying to use vast.ai. Renting a GTX1080, I started with a docker image caffe2ai/caffe2:c2.cuda8.cudnn5.ubuntu16.04 (this is one of the default options on vast.ai).

    Building the final product requires building caffe first as mentioned in the instructions, which I was able to successfully do. Then, I was able to build the actual waifu2x-caffe program, but upon running it, I just get an error message which I think translates to "cannot be converted":

    エラー: 出力画像「out.png」が書き込めませんでした

    変換に失敗したファイルがあります

    I feel like I'd gotten so close, but unable to do it. I have a few ideas:

    - use cuDNN 5.0 instead of cuDNN 5.1 which is what the docker image comes with. However, doing this makes it difficult to build caffe (keep coming across the same github issues with answers that don't work).

    - extending from this, pulling from an older commit closer to when the author originally created the install readme file, to try and exactly replicate the conditions to when he got it to work.

    I'm at my wits end because of this, I'm not a particularly experienced programmer yet but just wanted to use this tool for a hobby project.

    tl;dr I just want to run waifu2x-caffe for ubuntu on a vast.ai instance but it's so hard.

    submitted by /u/letterspice
    [link] [comments]

    How to find a spot in an 2d array thats x spots away

    Posted: 05 May 2019 08:29 PM PDT

    Not sure if this belongs here, but I'm trying to, mathematically, find the index of a spot on a 2d array that's x amount of spots away. As in if you have a 6x6 plot and you're at 1,0 and you're trying to find what's 5 spots away how would you calculate that. It would be (0,1)

    I want to do it in away that's not using the two 4 loops method becuse if I have a large array and looking at a spot very far away it'll take a while.

    edit I should clairify i mean like so many spots away. I'm doing horizontally with wrapping. so if you're at 0,0 and want to move 3 spots away you'll be at 0,3.

    submitted by /u/mshcat
    [link] [comments]

    Need help from tech industry employees with a short survey.

    Posted: 05 May 2019 05:27 PM PDT

    Hello!

    I would love to get some help with a school project regarding motivation to work and if gamification elements at the workplace could help the motivation. We are focusing on the tech industry so i thought this might be a good place to get some answeres. It will only take 2 minutes!

    It's really appreciated! Thank you in advance!

    (This survey is completely anonymous and can be terminated at any time)

    I couldn't find any rules if this is okay to post this survey here or not. Apologize if that would be.

    Motivation & gamification at the workplace

    submitted by /u/aleexn
    [link] [comments]

    Could any help me add to my JS of using a button to make an output based on options selected on two dropdown menus?

    Posted: 05 May 2019 06:25 PM PDT

    Below is my JavaScript that Includes tow drop-down menus to select where one would be picked up and dropped of, I would like to add a button where after two locations are selected it would create an output of a fair. I am guessing I would need what if statements to assign a fair to each combination of pick up and drop off location. Could anyone help complete my code?

    <html>

    <h2> Find A Ride </h2>

    <body>

    Where do you want to be picked up from and dropped off?

    <br>

    Pick Up ......... Drop Off

    <br>

    <select>

    <option value="Ajax">Ajax</option>

    <option value="Brampton">Brampton</option>

    <option value="Burlington">Burlington</option>

    <option value="Guelph">Guelph</option>

    <option value="Hamilton">Hamilton</option>

    <option value="Kingston">Kingston</option>

    <option value="London">London</option>

    <option value="Markham">Markham</option>

    <option value="Mississauga">Mississauga</option>

    <option value="New Market">New Market</option>

    <option value="Oakville">Oakville</option>

    <option value="Oshawa">Oshawa</option>

    <option value="Ottawa">Ottawa</option>

    <option value="Pickering">Pickering</option>

    <option value="Scarborough">Scarborough</option>

    <option value="St Catharine">St Catharine</option>

    <option value="Toronto">Toronto</option>

    <option value="Vaughan">Vaughan</option>

    <option value="Waterloo">Waterloo</option>

    <option value="Whitby">Whitby</option>

    </select>

    <select>

    <option value="Ajax">Ajax</option>

    <option value="Brampton">Brampton</option>

    <option value="Burlington">Burlington</option>

    <option value="Guelph">Guelph</option>

    <option value="Hamilton">Hamilton</option>

    <option value="Kingston">Kingston</option>

    <option value="London">London</option>

    <option value="Markham">Markham</option>

    <option value="Mississauga">Mississauga</option>

    <option value="New Market">New Market</option>

    <option value="Oakville">Oakville</option>

    <option value="Oshawa">Oshawa</option>

    <option value="Ottawa">Ottawa</option>

    <option value="Pickering">Pickering</option>

    <option value="Scarborough">Scarborough</option>

    <option value="St Catharine">St Catharine</option>

    <option value="Toronto">Toronto</option>

    <option value="Vaughan">Vaughan</option>

    <option value="Waterloo">Waterloo</option>

    <option value="Whitby">Whitby</option>

    </select>

    <script>

    </body>

    </html>

    submitted by /u/ProfessorAwesome67
    [link] [comments]

    Script not working in any browsers

    Posted: 05 May 2019 12:46 PM PDT

    [edit]: SOLVED - the culprit was a stray word within the variable declarations

    I have been spending an hour looking through this line of code within my script to find the problem, but nothing seems to trigger my prompts. Once the user opens the page it will ask them for the amount of numbers they'd like to use and then to enter their numbers, then the page would be overwritten with the results of their numbers.

    However, when it's being opened nothing pops up for a prompt. [a friend helped me find the script and method to do the assignment which is fine but I wanted to see what was the issue because the original had nothing wrong with it because it ran]

    This is my first post so I'm very sorry if this isn't formatted correctly (especially since I couldn't find the community rules anywhere - please link me to them if anyone could help me with that I rather not give off a bad first impression)

    - - -

    imgur link for assignment: https://i.imgur.com/lBMMnkh.png

    pastebin: https://pastebin.com/XEkXvBGM

    submitted by /u/partange1
    [link] [comments]

    Onetime password as login

    Posted: 05 May 2019 03:27 AM PDT

    Want to make a onetime password sent by sms per login in Python Flask app.

    1. user is asked for mobilenumber.
    2. sms with onetime password is sent.
    3. app checks if password == onetime password
    4. user is authenticated or not.

    Anyone made such a solution? Or any tips on how to proceed?Any best practices when it comes to security?

    All tips, github links or code examples are appreciated :).

    submitted by /u/klovlid
    [link] [comments]

    Input and Output?

    Posted: 05 May 2019 02:47 PM PDT

    Given input and the ability to give output, which programming languages would be the best at creating apps to analyze the meanings of data.

    submitted by /u/lunarman52
    [link] [comments]

    What programming language can be used in building industry?

    Posted: 05 May 2019 08:26 AM PDT

    Crime database with location of the crime?

    Posted: 05 May 2019 12:03 PM PDT

    I get alot of databases with raw statistics but nothing on where the crime was

    In a perfect world I would want the city/town it was in and preferably state by state

    Haven't found it and I'm 2 days into the search. Any help is appreciated, thank you

    submitted by /u/Raging_Bull6969
    [link] [comments]

    How do I learn how to use many tools that are common in programming.

    Posted: 05 May 2019 07:48 AM PDT

    So I know how to program. I can make an if statement, sort an array, whatever. That stuff is easy for me to figure out.

    I don't know how to do many other things that most would consider important for programmers to know. I don't understand what Gradle is, Maven, etc. I don't know how to use packages in programming languages. I don't know how to build projects. I don't know how to use git.

    All I really know is that if I press compile in blueJ and click on a program and run main it works. I know how to run python on my computer but not how to make a program others could use in Python. I know how to compile golang and run it, but that's easy as it compiles to an exe.

    I just feel like despite me knowing how to program I don't know how to do a lot of essential things.

    submitted by /u/TeknicallyThrowAway
    [link] [comments]

    Why don’t websites append the username to the password before hashing it?

    Posted: 05 May 2019 12:28 AM PDT

    I just can't think of a downside to it. Everyone would have a unique hash so you would have to target a specific user to get their password.

    submitted by /u/W0lfgangster
    [link] [comments]

    Python task help (basic)

    Posted: 05 May 2019 09:08 AM PDT

    Im making a dice poker game for assignment and stuck (newbie here) on a question for ranking hands question is as follows

    "Determine the rank of the player's hand (i.e. an integer value between 0 and 6 as described in the section 'Dice Poker Game Play and Rules'). Hint: Use the die_count list that holds how many times each die face value was rolled in order to determine the rank of the hand."

    im not allowed to use .count() or any list methods

    Im basically just trying to assign ranks based on the hand that was rolled between (0 - 6) 0 being no pairs rolled and 6 being five of a kind

    Say we have a starting point of 1 pair = 1 point, if we have [0, 1, 2, 2, 0, 0, 0] we have 2 pairs, so that would be 2 points, so we then determine that Rank 2 (two pairs) i tend to get stuck on how to rank 2 pairs as it has 2 of the same number in list.

    Whats the best way of ranking the hands using a loop?

    here is my code so far

    import dice

    import random

    player_hand = [0, 0, 0, 0, 0]

    computer_hand = [0, 0, 0, 0, 0]

    die_count = [0, 0, 0, 0, 0, 0, 0]

    die_count2 = [0, 0, 0, 0, 0, 0, 0]

    i = 0

    l = 0

    for x in range(5):

    player_hand[x] = random.randint(1,6)

    computer_hand[x] = random.randint(1,6)

    while i < 5 :

    die_value = player_hand[i]

    die_count[die_value] = die_count[die_value] + 1

    i = i + 1

    while l < 5 :

    die_value = computer_hand[l]

    die_count2[die_value] = die_count2[die_value] + 1

    l = l + 1

    print ("Player's hand:")

    dice.display_hand(player_hand, 5)

    print (" ")

    print ("Computer's hand:\n")

    dice.display_hand(computer_hand, 5)

    print (str(die_count))

    print (str(die_count2))

    submitted by /u/Markypaulson7
    [link] [comments]

    How would I go about combining c++ and python?

    Posted: 05 May 2019 04:35 AM PDT

    Basically as a learning exercise I want to create a bullet hell/vertical shooter game where the quick calculation are done with c++ and handle the rest with python.

    Is this possible or recommended?

    submitted by /u/SpeedWagon2
    [link] [comments]

    Python path question

    Posted: 04 May 2019 10:24 PM PDT

    Hello, I have the following python file called 13.py contained within a directory called Exception Handling and this directory is within Data.

    The Terminal pwd command says 13.py is in /home/Data/Exception Handling

    13.py contains...

    try:

    f = open('file.txt')

    line = f.readline()

    i = int(line.strip())

    except (IOError, ValueError) as e:

    print("file is read-only or can't be converted to int", e.errno)

    except: print("Unexpected error")

    file.txt contains...

    okay

    I can run this Python program (meaning I know it's opening the file and will encounter a ValueError; which is the aim) when file.txt is sitting in the home directory. When I place file.txt in the directory of 13.py, I can't get it to open the file properly (my general except is telling me that I'm not opening the file). I've tried different paths to put inside the open function.

    What is the valid path (argument for the open function) when file.txt is inside the same directory as 13.py?

    submitted by /u/Bloke-Grog
    [link] [comments]

    No comments:

    Post a Comment