• Breaking News

    Tuesday, March 23, 2021

    What is the computational complexity of minimax *verification*? Ask Programming

    What is the computational complexity of minimax *verification*? Ask Programming


    What is the computational complexity of minimax *verification*?

    Posted: 23 Mar 2021 02:40 PM PDT

    I have a tree of depth D with branching factor B. Each leaf node has a computable value.

    I would like to verify whether a candidate leaf node is 'the minimax value' (the principle variation). What is the computational complexity of this task?

    Is it still O(BD/2 ) as with the alpha-beta pruned minimax algorithm?

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

    Why is this algorithm for calculating primes slower?

    Posted: 23 Mar 2021 04:42 PM PDT

    Hey! I've been looking at implementations of the Sieve of Eratosthenes, and I found that the methods online use a big chunk of RAM to store the array. Since any composite number n consists of primes < sqrt(n), I can just make an array containing all of the primes I've already found and then test if n is divisible by any of the primes up to sqrt(n).

    This method indeed works, but for some reason, it's not as fast. I compared my results to this article, in which he found around 50 million primes in 36 seconds. In contrast, my algorithm took 51 seconds to find 10 million primes, which means the algorithm in the article is over 7 times as fast! What confuses me the most is that it was done using Java on a low-end computer, while I'm using Rust on a better processor.

    Is there a reasonable explanation for why my algorithm is slower? Are there any ways I can optimize it?

    Instead of dumping my code on Reddit, I've made a gist. It's written in Rust, but it should still be relatively comprehensible.

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

    Getting Same Camera Video Stream with Two Different Programs

    Posted: 23 Mar 2021 04:28 PM PDT

    For various reasons, I have two programs on the same laptop trying to access the same camera stream coming from an intel real sense video camera coming from my laptop. Like expected, it does not work because only one program can access the video camera.

    Is there a way I can get both programs to access the same video stream? Or do I have to resort hosting a local server that gets video feed from the camera? If so, how do I do this in an efficient way? I have to get the camera streams fairly fast from both my programs.

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

    What's the best pathfinding approach in 100x100 grid?

    Posted: 23 Mar 2021 04:56 PM PDT

    I know there's A* but is there sth faster? I don't need the best possible path I need a path, but quickly computed. It must just avoid obstacles.

    My problem is that I'd like the program to spit out ~ 500 paths between different points per second.

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

    Why is Insertion Sort about 12 times faster than Bubble Sort when input data is already sorted?

    Posted: 23 Mar 2021 07:49 AM PDT

    Edit: [Solved] Turns out the input data was not a sorted list but two sorted lists concatenated.

    Given that the input data is already sorted, why does insertion sort run about 12 times faster than the most optimized version of bubble sort?

    Insertion Sort:

    void insertion(string a[], int n) { for (int i = 1; i < n; i++) { string temp = a[i]; int j; for (j = i-1; j >= 0 && temp < a[j]; j--) a[j+1] = a[j]; a[j+1] = temp; } } 

    Bubble Sort:

    void bubble(string a[], int n) { while(n > 0) { int lastModifiedIndex = 0; for (int currentIndex = 1; currentIndex < n; currentIndex++) { if (a[currentIndex - 1] > a[currentIndex]) { swap(a[currentIndex-1], a[currentIndex]); lastModifiedIndex = currentIndex; } } n = lastModifiedIndex; } } 

    This was taken from an assignment I had. Among other things, the assignment asked us to run insertion, selection, and bubble sort on sorted, random, and reversed data and compare the results of each sorting algorithm. The code for the insertion and selection sort was given while the code for bubble sort was supposed to be written by us. I used the most optimized version of bubble sort as seen above.

    Upon running the sorting algorithms on sorted data, insertion sort took about 2.5 sec while bubble sort took 29.5 sec. I tried to understand why insertion sort was that much faster than bubble sort knowing that both algorithms have a Big-O (or Big-Omega in this case; I am not sure) of O(n) on sorted data. I read through the code carefully and found that both algorithms do the same amount of comparisons but insertion does more data movement (assigning to temp variable and then reassigning temp to the same value in the array essentially not not changing anything). So, why is insertion sort faster than bubble sort in the case where data is already sorted?

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

    Generate json script from excel list

    Posted: 23 Mar 2021 05:25 PM PDT

    I apologize if my terminology is all over the place, noob and German over here.

    Basically TSP. I have a geocoded list of addresses in Excel. The idea is to route optimize those addresses with the Graphhopper Route Optimization API by curling

    curl -X POST -H "Content-Type: application/json" "https://graphhopper.com/api/1/vrp?key=YOUR_CREATED_API_KEY" --data "@tsp.json" 

    a json script with locations in it like this

    { "id": "hamburg", "name": "visit_hamburg", "address": { "location_id": "hamburg", "lon": 9.999, "lat": 53.552 } 

    "hamburg" would of course be the address. So, how could, say, 100 of these, get generated into a json script that also has other code before and after?

    I'd love to know what to look into to accomplish this. I'm guessing it's fairly basic but a Google search couldn't answer the question, so thanks for taking the time bros

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

    "window.print();" prints broken or unloaded images

    Posted: 23 Mar 2021 03:07 PM PDT

    I am using it on pages that don't have the print functionality on chrome for android

    by typing "javascript:window.print(); in the url bar.

    also the background graphics that on the chrome desktop print pdf ....isn't there

    https://i.ibb.co/KzDmYZW/image.png

    how can i get it to work probably ? or is there any alternative method ?

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

    Dynamic programming question

    Posted: 23 Mar 2021 08:38 PM PDT

    What part of the tree gets priority ? Does it matter? I'm assuming it does since if the right hand side gets priority vs left, the one with more value gets to store the value faster and can cover more cases, and since it is synchronized programming, there has to be an order.

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

    which language to choose game development

    Posted: 23 Mar 2021 08:19 PM PDT

    I have no coding experience but since there is a outbreak in world i want to learn something and improve myself in game development which language i should choose and what kind of way should i choose to not get overwhelmed

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

    Need help trying to "convert" loop to x86 asm (at&t)

    Posted: 23 Mar 2021 07:06 PM PDT

    Hey guys,

    I'm trying to write this loop in assembly: `` for (int i = 0; i < 10; i++) { printf("%d\n", i); }

    ``

    And this is my code so far in assembly:

    `` .file "loop.s"

    .section .rodata printf_msg: .string "%d\n" printf_top: .string "loop top\n" printf_end: .string "loop done\n" .text .globl main .type main @function main: pushq %rbp movq %rsp, %rbp movq $0, %r10 # i counter movq $10, %r11 # "length" looptop: movq $printf_top, %rdi call printf cmpq %r11, %r10 jge done # i > 10 movq $printf_msg, %rdi movq %r10, %rsi movq $0, %rax call printf incq %r10 jmp looptop done: movq $printf_end, %rdi call printf leave ret .size main, .-main 

    ``

    I'm getting an infinite loop which I guess means it's an issue with the condition checking, but I'm not sure why it's not exiting properly?

    Any help would be greatly appreciated, thanks!

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

    Need advice on how to make this project, best course of action? (mainly Python related - maybe others)

    Posted: 23 Mar 2021 05:56 PM PDT

    Hiya,

    Basically I have an idea that I want to implement - mostly in Python as that's what I'm comfortable with - though I'm happy to use other tech/languages where needed.

    The Idea: A game played via email. 0 - 10 players per game. User signs up and confirmation is sent to all players email. Once they confirm game is started. Game is turned based so there will be quiet a bit of back and forth emails as everyone takes their turn.

    Now to the question: If you faced this task, what is the general layout of the back end and what modules/framework would you use?

    I've written scripts that parse email inboxes before, but never on this scale- so I'm thinking each game played will be it's own individual instance with a new email spooled up to only be used for that instance (eg. 12322241@mygame.com"

    Running multiple games concurrently like this will require threading I assume? What sort of framework/module would be ideal for me to use? Django? Flask? The easier to use the better, I've used Django before just to make static websites

    Or will I be better off trying to create a custom server to respond to the clients

    Thanks in advance and any tips/ideas for the best way to implement this would be greatly appreciated! :)

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

    How can I version control a SQLite database?

    Posted: 23 Mar 2021 11:19 AM PDT

    I'm currently building a desktop time-management application (using Python with SQLAlchemy) that uses a SQLite database to store its data.

    In my application, I want to provide a feature that allows the user to revert their changes (so that they can for example go back to an application state 5 days ago).

    After reading the SQLite documentation and searching around online, it doesn't seem like SQLite offers any built-in version control capabilities.

    I was thinking about using a Git repository to track the SQLite database file and manage the version history. Is this a good idea, or is there a better way to version control the database?

    Thanks.

    submitted by /u/1us3arch
    [link] [comments]

    Dear programmers of reddit this is a question from a beginner (me)

    Posted: 23 Mar 2021 10:29 AM PDT

    I started learning java 3 days ago.. and I can pretty much comprehend much of the basics.. my question is when does things getting serious and it's time to reconsider your choices.. or will this phase ever arrive? Will it get so much difficult that I may be considering to leave it? I started java because I was a python user before and thought to once agin step into the coding game but this time be serious about it and do some real hardwork with a new language and a fresh start.

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

    [HTML] Problem with img src

    Posted: 23 Mar 2021 01:55 PM PDT

    <td style="border: 2px solid midnightblue;"> <img src="United Nations Convention on the Rights of the Child.jpg" height=600 width=500></td>

    <td style="border: 2px solid midnightblue;"> <img src="UNICEF Henrietta Fore-Head.jpg" height=400 width=300></td>

    <td style="border: 2px solid midnightblue;"> <img src="Founder of Unicef - Ludwik Rajchman" height=400 width=570></td>

    This is the code specific to the section, but when I load up the webpage, the ludwik rajchman part is not visible and comes up with that little picture of a hill and cloud in the top right part of the picture, and nothing shows.

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

    Domain Driven Design: Which book should I read?

    Posted: 23 Mar 2021 07:17 AM PDT

    The DDD term is almost found everywhere and I want to know more about it, so I'm planning to buy and read a book.

    When I google this I always come across "Domain-Driven Design: Tackling Complexity in the Heart of Software" from Eric Evans. Unfortunately this book is from 2003 so I'm afraid that it's outdated.

    What's your opinion on the book?
    Are there newer books which are more up-to-date?
    Which book would you recommend one who has a rough idea about DDD but wants to get to know it much better?

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

    [HTML]Problem with borders and tables.

    Posted: 23 Mar 2021 12:57 PM PDT

    <td style="border: 1px solid navyblue;"> The United Nations Convention on the Rights of

    the Child is the basis of all of UNICEF's work</td><br>

    <td style="border: 1px solid navyblue;"> The current Executive Director of UNICEF is

    Henrietta H. Fore

    <td style="border: 1px solid navyblue;"> Their founder is Ludwik Rajchman, who was a

    Polish physician and bacteriologist

     </tr> <tr> 

    <td style="border: 1px solid navyblue;"> <img src="United Nations Convention on the Rights of the Child.jpg" height=700 width=500></td><br>

    <td style="border: 1px solid navyblue;"> <img src="UNICEF Henrietta Fore-Head.jpg" height=400 width=300>

    This is the code. My problem is that I have put it in a table, but it isn't appearing. It simply shows the text and the pictures

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

    I need help in running a Github code

    Posted: 23 Mar 2021 12:31 PM PDT

    hello how are you doing i have been trying to run this twilio/twilio-video-app-react: A collaboration application built with the twilio-video.js SDK and React.js (github.com) IDK why an error occurs while deploying the app in command npm run deploy:twilio-cli
    the error:
    npm ERR! missing script: deploy:twilio-cli

    npm ERR! A complete log of this run can be found in:

    npm ERR! C:\Users\AppData\Local\npm-cache\_logs\2021-03-23T19_27_40_693Z-debug.log

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

    question; looking for a program: what program would you advise for data management with filters

    Posted: 23 Mar 2021 11:44 AM PDT

    if i'm on the wrong subreddit, please tell me where i should go. also, if i'm using the wrong terms, please correct me so i can change them. if something similar has been asked before, please redirect me, or tell me the terms i should use in my search.

    i am looking for a way to make a sort of searchable database, in which i can add multiple filters. first off, i am not a programmer, and most of my programming experience atm revolves around the very basics of Rstudio - which although powerful, seems more like a data processing than a data management, sorting & retrieving program.

    i want to make/use a free program/tool to make a searchable database, with which i can add multiple tags to entries, and then search by tags. if possible, different tags in different categories; similar to most webshops. that way, i can easily select the tags that relate to my search, and then only those will show up.

    context: i'm studying in a medical field, and want to make a database in which i can store and sort all the things i'd have to know, for future reference, and perhaps as a future practical tool. the info i'd want to put in it would be centred around organising symptoms, and their associated diseases - with (making it up as i'm typing) a drop down or open-able info box with additional info - ,and treatments. thus if i have limitless amounts of tags i can add to each disease, i can make it as specific as i can, and add both generic and more specified tags, depending on the amount of info there'd be in each case.

    also, it would be very useful if it was either made into or by a single app, so that it could be shared with other people in the same field, and might possibly end up being a learning tool. thus, being openable on both windows and mac would be very nice. if it was readable on a phone, that would be even better, but is not a requirement.

    preferences/requirements: must run on windows, if possible mac also. ideally be/make a stand alone readable file/executable. maybe in a common format that would allow export to certain apps. must be accessible offline (for editing offline is not necessary)

    i don't mind if i have to learn (some) programming. if i am on the wrong subreddit, please redirect me. if you think i'm lazy for not googling myself, then please tell me the terms that describe such a program, then i can look for it (also appreciated if you don't think i'm lazy).

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

    chrome auto focus on text field

    Posted: 23 Mar 2021 11:03 AM PDT

    Apologies if this isn't the right sub for this question. If it isn't I'd be happy to be redirected to the correct sub.

    So I work in a warehouse and use heldheld barcode readers on desktops mostly. I have two computers I use regularly and one of them does something the other doesn't and I'm not sure why. One computer will automatically focus on a text field when the page is opened and the other doesn't. This is somewhat only a small inconvenience but it can be very disruptive for me and I'd like to find a solution. I am happy to elaborate if need be. please let me know.

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

    How to print the correct filename when modifying a filesystem?

    Posted: 23 Mar 2021 10:00 AM PDT

    In this code, I am monitoring the filesystem. Whenever I modify a file, event.src_path does not show the name of the file. Instead, it shows .goutputstream-CL5N00. I don't know what is wrong?

    Given result

    event type: modified path : /home/bilal/Videos/folder1/fd/.goutputstream-CL5N00 

    Expected result

    event type: modified path : /home/bilal/Videos/folder1/fd/touch 

    Code

    class MyHandler(FileSystemEventHandler): def on_modified(self, event): print(f'event type: {event.event_type} path : {event.src_path}') def monitor_folders(path): event_handler = MyHandler() observer = Observer() observer.schedule(event_handler, path, recursive=True) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join() folder1 = '/home/bilal/Videos/folder1' if __name__ == "__main__": m1 = monitor_folders(folder1) m1.start() m1.join() 
    submitted by /u/ibilalkayy
    [link] [comments]

    DHT Kademlia node ID multiple IP's - Increasing node availability

    Posted: 23 Mar 2021 09:09 AM PDT

    Hello Community,

    I am conceptually working on increasing the availability of a compute node that relies on a Kademlia hash table for information on all its peers.

    My question is, if I were to run a Kademlia daemon bound to multiple public interfaces, how would my peers store my node information?

    If my node A generates node ID 011 and is round-robin routed out of 1.1.1.1 and 2.2.2.2 on ports 1234, would my peers see me as two nodes or one node with two IP addresses?

    Rephrasing my question, is a node's state linked to the node ID or the entire node entry (Node ID, IP Address, UDP Port)?

    The problem I am trying to solve is ensuring that a node stays up by implementing some form of L3 redundancy. There are many ways to skin that cat, but I am working my way up the OSI model and out from the actual node in complexity.

    Thank you for any input,

    Rudolf

    Reference paper I used for Kademlia:

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

    Which Database should I choose ?

    Posted: 23 Mar 2021 06:08 AM PDT

    Hello reddit ! I'm working on a react native app that requires to display available restaurants on the map (I will retrieve the restaurant's properties like : the name, the address, the phone number, and the latitude longitude coordinates from a database) Add to that I will have to display the number of available chairs/places in each restaurant in real time to other users, so the number of available spots in each restaurant will be regularly updated ( every time a customer leaves / gets into a restaurant) So, in your opinion, in my case, which database would be most applicable for this situation ?

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

    Change from C++ to Java

    Posted: 23 Mar 2021 02:05 AM PDT

    Hi, right now I'm a C++ developer with bout one and a half years of professional experience. I have no Java experience whatsoever. How hard would you recon it would be to switch? I'm asking because I saw a really interesting job opening.

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

    No comments:

    Post a Comment