instruction stringlengths 71 95.1k |
|---|
Basically I have done a code for a project which works with a shift and ctrl selection. The program consists of a chart with specified points, which the user is able to select with the different key controls in order to move them. The highlightedIndex is a list of int. I am also working with WPF and later on I have t... |
[Base on https://codeforces.com/contest/1360/problem/G]
So my logic is to process each column at a time and find b rows such that the total 1s in them is less than a and if there are many candidates I take the rows with least 1s.
import Data.List
import Data.Array
import Control.Monad
-- i... |
Hello everyone!
I wrote a class Vector.So, I want to find out how can i upgrade it for better performance of my vector.
Here is the code:
template <typename Type>
class Vector
{
private:
size_t _size;
size_t _capacity;
Type* _data;
public:
Vector(size_t capacity = 0);
Vector(const Vector& vec);
... |
I have this python script that uses pandas read an excel sheet then to update a sqlite db it works perfectly just wondering if I can speed it up as I am at about 70k lines
"""
Created on Thu Aug 1 14:11:01 2019
@author: Shane Pitts
"""
# -*- coding: utf-8 -*-
import sqlite3
from sqlite3 import Error
import pandas as... |
Question:
You are given n words. Some words may repeat. For each word, print its number of occurrences. The output order should correspond with the input order of appearance of the word.
Sample Input:
4
bcdef
abcdefg
bcde
bcdef
Sample Output
3
2 1 1
Here's what I came up with:
n = int(input())
array = []
elements = {... |
I am currently taking an introductory course in computer architecture.
Our goal was to write a dot-product function in x86 Assembly which would use SSE and SIMD (without AVX).
I am not to that confident with my solution:
#include <time.h>
#define NUM 25600
//Example: scalarProduct using SIMD
extern float scalarProduc... |
This is a follow up of A simple definite integrator class of a single variable in C++.
I took most of the advice from Emma X and some from sudo rm -rf slash.
Here is my fully revised code:
Integrator.h
#pragma once
#include <type_traits>
template <typename Field>
struct Limits {
Field lower;
Field upper;
... |
I am new to Python and following tutorials.
This one I came across was for TKinter, and throughout I felt I re-wrote the same lines of code time and time again which I wondered if it could be better written.
I am interested to know how you would improve this code.
Thanks.
(First time posting, hope it's ok).
from tkinte... |
I had this question in an interview recently. Given a sorted array of integers, return a list of those integers squared, with the squares sorted. So given an array of these numbers:
-5, -3, 1, 2, 4
the result should be this:
1 4 9 16 25
I came up with this solution using Java 8 streams, but is there a way to do thi... |
I started learning from the book: head first design patterns. As I am trying out different programs in the book, I am compiling them in this one demo app. Below is the code for its driver function. Can anyone guide me with any improvements to the program (related to style, programming, formatting, how to test, is it be... |
The following bash script was made to retrieve some local repository information in order to be used to display a condensed git status in terminal PS1 prompt.
It performs some simple greps over (git status) --short version text to display 6 repository status: Commits ahead, commits behind, added files, modifiled files,... |
I wrote some code that reads the output of the rcon users command on the CS 1.6 console. It then notifies me of any players that are not in my whitelist.csv or are in my blacklist. The program requires 3 files as inputs:
A text file containing the raw output of the rcon users command on CS 1.6 console.
A CSV file cont... |
I have built this Generic Graph traverser, I have this implemented with DFS, I feel it will work equally fine with BFS too.
What do you think of this implementation?
I want help in reviewing the Visitor interface.
Should I have Generics in it or just use the base Object?
public abstract class GraphTraverser {
prot... |
Just for practice purposes, I written a basic client sided login/signup system that allows you to make an account, and then log into the account from my webpage. What it does is append to an object known as database for every new account made, and when you sign in, it loops through the database and see if your credenti... |
Suppose I have a vector containing n elements. I want to find out the number of previous elements greater than its element at present index i. I want to find A[i] > A[j] && i < j for all elements of the vector.
Constraints:
1 <= t <= 1000
1 <= n <= 10^5
1 <= A[i] <=10^5
My code:
#include<bits/stdc++.h>
using namespace... |
I want to calculate the correlation time. First I calculate the auto-correlation function:
$$
\begin{align}
\chi(t) = &\frac{1}{t_{max}-t}\sum\limits_{t'=0}^{t_{max}-t}m(t')m(t'+t)\\
&-\frac{1}{t_{max}-t}\sum\limits_{t'=0}^{t_{max}-t}m(t')\frac{1}{t_{max}-t}\sum\limits_{t'=0}^{t_{max}-t}m(t'+t)\\
&\sim e^{-t/\tau}
\end... |
I want to create a MVVM-C project, but also adequately test it. Naturally I want to create such a project that can access a Network Service.
Any comments or thoughts on this approach?
DependencyFactory:
protocol Factory {
var networkManager: HTTPManagerProtocol { get }
func makeInitialViewModel(coordinator: Coo... |
I have a following table in a flask app
class Price(db.Model):
__tablename__ = "prices"
id = db.Column(db.Integer, primary_key=True)
country_code = db.Column(db.String(2), nullable=False)
value = db.Column(db.Float(precision=2), nullable=False)
start = db.Column(db.DateTime(timezone=True), nullable=... |
I am a beginner in Python, as you will see looking at my notes.
This is a program that simulates seat booking in a cinema for example.
The program stores the users name as a key and the seat(s) they have chosen in a dictionary as key-value
pairs.
What are the ways I can improve this program? I have used one function. W... |
Background
About the Fleissner-Grille
The Fleissner-Grille is a really easy possibility to encrypt text.
You just have to take a grid of size n*n with (n*n)/4 holes (example). You then just write one letter in one hole. After you've filled every hole with a letter, you just turn the grille by 90° degrees and start agai... |
I am new to JavaScript so I am not sure if it's bad practice to nest a for loops inside of each other.
This script simply takes a WordPress HTML menu and restructures it into a format better suited to my requirements.
Below you can see the original HTML, the JS and the new HTML output by the JS.
The nested "for of" lo... |
I am trying to learn how to effectively use error handling in my code. To do this, I have created a class inside main.py which reads the value of a specified curve at a specified date.
I then have my file data_reader.py, which reads in the specified curve (into a Pandas dataframe) from a CSV file. The index of this cur... |
I'm new GO coder (stared this Sunday) coming from different backgrounds, I wrote the below code based on my understanding of Go within these couple of days, and impacted of my experience in other languages, I like to share for Go experts review/comments and feedback.
package main
import (
"fmt"
"log"
"sort... |
I developed Awk code to print all primes till N where N is given as command line argument. I think I took pretty much all the optimizations into account. Could someone help if it could be optimized even more. The code is as follows:
#!/usr/bin/awk -f
BEGIN{
for (i=oddify(ARGV[1]); i>2; i=i-2){
flag=1 #prime
... |
I'm pretty new to Python and really new to PyGame. My snake game runs, but I guess that's not really saying much. I would appreciate feedback on the layout, techniques, or best practices of my code.
import pygame,sys,random,time
from pygame.locals import *
#Setup pygames#
pygame.init()
#Setup the window#
WINDOWWIDTH... |
I am building a browser based Pre-Flop HUD that for now just tracks VPIP, PFR and number of hands played for an opponent (https://pokercopilot.com/poker-statistics/vpip-pfr). I am currently using local storage to store my data. In the future I will use a better persistence strategy, add more features, and find a way to... |
I'm working to understand Big O notation. As such I'm going through examples and the algorithm below generates the permutations for a given input string which contains only distinct characters. IE no duplicated or repeated characters in the input string.
My thought process was to take each character and place it at eve... |
The task is to write a function, which capitalize the first letter of all words in a string. For this we'll class a word as any characters separated by a blank. Because the standard String.capitalize method only capitalizes the first character of the string I have written the following.
Could the task be accomplished w... |
The idea was to write a context manager that would calculate energy consumption for the given machine learning pipeline running on a GPU. It does it by polling the current power consumption using the nvidia bindings library pynvml.
The energy consumption is then calculated in KWh.
The total pipeline consumption is the ... |
Code is running ok but need to be reviewed for any limitations / possible improvements. Not sure will work in all scenarios because of the number of ifs and else and length of the macro. Referred to this question on Stack Overflow.
Sub StringCompare2()
Dim Rg_1 As Range, Rg_2 As Range, Rg_3 As Range
Dim cL_1 As Range,... |
I've been trying to learn React and I'm currently building a time-tracking application. The-end goal of the app will be for users to be able to track time against different tasks from different projects.
This is the stopwatch component I have built, with a start, end and reset button, and I would like to get a code rev... |
I'm sending and receiving data over an interface (serial in this case) with the following behaviour:
The receiver sends back an Ack message if a message is delivered successfully.
If an Ack is not received within a timeout, the command should be re-sent limited a number of times.
Multiple clients may request sending a... |
Does this process look protected from SQL injection attacks?
Is there something I could possibly change to make it more protected?
<?php
include("../include/database.php");
if(isset($_POST['details']))
{
$values = $_POST['details'];
$param1 = htmlspecialchars(trim($values['param1']));
$param2 = ht... |
I have just finished implementing a version of Conway's Game of Life using Java.
Being only a college student, I am sure that my code is no where near perfect, and was wondering if you could look at my code. What can I improve on? Are there faster ways to implement certain areas of my code? Is there excess code that I ... |
I want to join two fragments into one string with a separator, but when one of the fragments is empty I only want one of them.
I have two implementations. The first is long and slightly repetitive, but I believe it is easier to understand, since it is a more step-by-step description of the process. The second is way sh... |
I quite often find myself checking whether a given value is present in a given, possibly nested, container. For example, is int val present in the nested container vector<vector<int>> values? To me this looks like a good opportunity to practice with template functions while also cleaning my code. I wrote the following ... |
I've written a simple mesh class. The purpose of it is to build a mesh, draw it to the screen, and provide some means by which the mesh can be transformed/scaled, etc. This was done with GLAD, GLFW, GLM, and OpenGL.
/*
The mesh class takes vertex data, binds VAOs, VBOs, drawing orders, etc, and draws it.
Other classes ... |
I have this code in my ViewModel which searches a List of Items, the OnSearchAsync(string searchQuery) gets executed by a Command which is bound to TextChanged Entry Event
The ObservableCollection<Items> Collection is bound to CollectionView. There are 200 Items max in this Collection
I'm wondering if my Code could be ... |
I made a program which simulates taking an order for 3 meals and a dessert.
It's like those packaged food companies you see on Instagram.
It asks for a name, and then goes on to ask what they want for each mealtime and stores their orders in a dictionary.
I defined two functions; they help out a lot and make it much ea... |
As an old COBOL coder, all this OOP stuff is foriegn. Would someone please take a look at this program? I'm looking for suggestions for ways to improve this program. While it works, I'm sure there's many way to make it better, particularly in the areas of memory management, OOP methodology, and idioms. Any advice is we... |
I've recently started working on an Angular 7 project (I'm pretty new to Angular and RxJS), and I was requested to implement this new functionality:
The Problem
I have to implement a component to show some data fetched from a server via a service, and allow the user to edit it. The HTTP call can be triggered after sele... |
I haven't used C++ in over a decade, so to learn modern C++ (17) I built a JSON reader based on a pushdown automata (PDA).
The general idea is this:
A stream is passed to JsonReader
JsonReader calls ParserStatesManager, which returns the next state based on the top of the PDA stack, and optionally by reading in an inp... |
I need to add some characters to a String before using it for an API call. The idea is to add a " char both at the beginning and at the end of the String, to make sure the API does an exact search for the input string.
Version 1:
StringBuilder(escapeJava(query))
.insert(0, DOUBLE_QUOTE_CHAR)
... |
i'm doing a Core for a Tic Tac Toe game.
I have my code with a dynamic size of the board (can be 2x2 to 10x10, if is 7x7 we need a 7 characters in a row to win , if is 4x4 we need 4 etc) , This code works for any matrix with any size and give me a bool state if someone won the game (they can use any character to mark ... |
Probably a dumb question but just can't seem to make a decision here.
I'm building a C# class library that I intend for other developers to use. Let's say one of these classes contains a method that accesses a remote resource and maps it to an object:
public class FooClient
{
public async Task<Foo> ShowAsync(strin... |
After spending a few months learning python I decided to build a basic Rock Paper Scissors game.
Basic construct of the game:
Allows you to pick best of 3,5,7
Allows you to put in the name
Computer choices are completely random
I know there are probably a million different ways to write this code. But based on the wa... |
I am a newbie and have been following a tutorial I bought on Udemy. But I was told it is old and teaches bad code practices. I used this in some code from my old projects. Now I'd like to know how secure it is.
Posts Upload:
<?php
error_reporting(-1);
require 'config/connect.php';
require 'auth_login.php';
require 'i... |
I'm developing a complex app with Spring Boot and MongoDB. I have a Video class like the following. Note: All getters setters are omitted.
class Video{
ObjectId _id;
private List<OReelOCategoryLGroup> listOfReelIdCategoryIdAndGroups;
//some other fields
}
public class OReelOCategoryLGroup {
ObjectI... |
I have often wondered how one would deal with dynamically sized arrays in C, since the only thing close is using malloc and realloc with pointers.
To find out how they work I decided that I should create a dynamic array in C.
xvec.h
#ifndef XVEC_C_XVEC_H
#define XVEC_C_XVEC_H
#include <stdlib.h>
#include <string.h>
/... |
Problem statement
In simple words it say, count total Strongly connected components in the graph.
All edges are undirected.
I have the following code that uses kosaraju 2DFS approach.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
public class AirlineProblem {
private static boole... |
I have huge number of text files, each several hundred MB in size. Unfortunately, they are not all fully standardized in any one format. Plus there is a lot of legacy in here, and a lot of junk and garbled text. I wish to check all of these files to find rows with a valid email ID, and if it exists then print it to a f... |
I am trying to solve a problem where I need to find the number of bracket sequences \$p\$ and \$q\$ such that for a given bracket sequence s. I have that \$p + s + q\$ is a valid bracket sequence. Also \$|p+s+q| = 2n\$.
We can use dynamic programming here, i.e. let dp[i][j] = the number of bracket sequences (which are ... |
I came across this question on Leetcode. The question description is as follows:
There are several cards arranged in a row, and each card has an associated number of points.
The points are given in the integer array cardPoints. In one step, you can take one card from the beginning or from the end of the row.
You have ... |
I have implemented directed graph and Dijkstra algorithm using heap in Python.
I first implemented an abstract base class WeightedGraph, of which DirectedGraph is a subclass. The DirectedGraph uses an adjacency map as its internal representation. I then implemented the method single_source_shortest_paths, which uses th... |
I am new to coding and need help with a code that won't complete. I suspect it is due to the size of the data set. I tested the code using a reduced data set and it processes fine. However, my actual data set is over 210,000 rows and is expected to grow.
Is there a way to speed this up? Thank you for your assistance
Su... |
As part of the task, it is allowed to use slightly outdated data. It is required that only one thread per key is involved in the critical section, while the remaining threads use data from the cache despite the expired TTL. The following code is an attempt to write a function calling the delegate within a blocking sect... |
I am trying to generate a Word document with two different tables inside it. For this purpose I have two similar methods where I am passing word document reference and data object and table to the similar methods.
I am looking to make single generic method. So in different places I can use single method and passing pa... |
I wrote a simple dice game with the purpose to practice arrays and classes. I would like some critique on my code structure and quality - as well as thoughts on my thoughts to improve it.
Here's the code:
import java.util.Random;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOExcepti... |
This script looks for a data attribute applied to elements within a specified wrapper.
It then sets all elements with the attribute to the same height (height of tallest div).
I needed to add a wait time as the script would sometimes get the heights of the divs before the page had fully rendered. Even though the await ... |
I have a mathematical problem about prime power. A number \$x\$ can be considered a prime power if \$x = p^k\$ where \$p\$ is a prime and \$k\$ is a non-negative integer. For example, \$81\$ is a prime power because \$81 = 3^4\$. Now, form a sequence of numbers in the following way. Start by taking a random number.
I... |
I wrote the following script which allows an element to be dragged and resized. I am mainly looking for suggestions regarding my JavaScript. In the future, it will also be possible to control the element externally. So the init() function is only temporary.
Github Live Page
Code on Github
JavaScript:
"use strict";
... |
I have a simple macro moving data from Teradata to Excel. The process normally takes me 10 minutes to perform manually, however the macro can run for hours sometimes. This is making the macro seems counterproductive. But I still want to give it a chance.
Manually, I would just simply paste the sql to teradata, and copy... |
I created a game which can play tic-tac-toe with: 0 players (AI vs AI), 1 player (human vs AI) or 2 player (human vs human).
Here is the AI function which wraps around my innermost function. This evaluates all the candidate board positions and returns the best move.
I searched to make sure this has not been implemented... |
I am working on a coding challenge for Tic Tac Toe. I am calculating the results and inserting them into the database.
However I have a long and messy if statement, which checks if the array's values match a valid win for O or X.
I feel like it could be refactored down but I'm unsure on how to approach this.
/** @v... |
To learn React I've ported a Vue combobox component into React. Because of the project it could be used in uses React 16.2 it doesn't use features like React.createRef() or hooks.
import React, { Component } from 'react'
import PropTypes from 'prop-types'
class ComboBox extends Component {
constructor (props) {
... |
I have collected a .csv file with some statistics about football games in the following format. Here is a sample .csv file.
Date,Home,Away,HomeShots,AwayShots,HomeBT,AwayBT,HomeCrosses,AwayCrosses,HomeCorners,AwayCorners,HomeGoals,AwayGoals,HomeXG,AwayXG
My code does the following:
Calculate a summary of statistics... |
This is a follow-up to my previous question about finding min and max values of an iterable.
Aho-Corasick algorithm was suggested to solve the problem. Below is my solution with the use of ahocorapy library.
Short re-cap of the problem:
You are given 2 arrays (genes and health), one of
which have a 'gene' name, and ... |
This script takes an image copied from the clipboard and analyzes the n darkest pixels of the image. It will loop through each found value, prints out the value information and the quantity, then displays the visual location of the pixels in a tkinter window.
There are two modes for reading the pixels. One is by simply... |
I've implemented a barreir in C++ close to one showed here. In the project code it's used only with two threads and seems to work. A synthetic test didn't expose any flaws too. But I suspect that on some machines it segfaults and/or falls through wait() call.
How do you think, can it fall through wait or is any race sc... |
I have a symmetric matrix and I want to loop over its elements. Currently, I'm using:
import torch
# sample symmetric matrix
W = torch.tensor([[0., 3., 0., 0., 0., 0., 0., 0., 0.],
[3., 0., 1., 0., 0., 0., 0., 0., 0.],
[0., 1., 0., 1., 1., 0., 0., 0., 0.],
[0., 0., 1., 0., 0., 0., 0., 0., 0.],
... |
I am creating a social network and I've been told a few times a lot of things are outdated and prone to SQL injections so I am going over everything with a very fine comb and checking what's good and what's not good enough to launch on the web.
I have my login and signup pages and I want to know if it's good to hold se... |
I'm learning C, so as a practice problem I implemented Conway's Game of Life. For anyone unfamiliar, the problem is set out here. To summarize, there is a grid of "cells" that can be either alive or dead. This grid is updated in "steps". In each step, live cells with 2 or 3 live neighbors survive, dead cells with 3 liv... |
this code is for return duplicates after sorted them, and also to
return the missed value between the limits of the given array, it's
executed correctly, but i need to optimize it so it excecute in less
time than it execute can any one help?
function findDupsMiss(arr) {
// your code here
var noDuplica... |
I have implemented a console calculator.
It has support for variables over a set of integers and the following operations: multiplication, integer division, exponentiation, addition and subtraction. You can use parentheses in expressions.
The SyntacticalAnalizer class implements parsing and syntactic validation of a s... |
We have 2 strings, say "JACK" and "DANIELS". We create two stacks from these strings, and then loop over them comparing first elements: whichever of the 2 goes first in lexicographic order gets popped from its stack and added to a string (the second value is left alone). So it goes, until we end up with a string contai... |
I have written a pretty simple hash table in C. It uses a prime modulus, linear probing, open addressing, and robin hood hashing.
The program can also be found on GitHub.
For clarification, uin is a typedef that uses uint32_t or uint64_t depending on whether the system is x86 or x86_64.
I'd now like to optimize the per... |
I have a program that lists and downloads a year of history of two stock tickers (AMZN and GOOG). I download these to a SQL database, C:\Databases\hist_prices.db, inside a table called hist_prices_tickers.
How can I organize my code for a more Pythonic approach?
I intend to use this SQL database for a machine learning... |
I'm learning JS and Canvas. A friend of mine gave me the task to create a Battle City replica. I've already managed to make the map and the player to move. Nothing fancy just some squares with a color, I tried to replicate the first map:
My code currently creates the map using 26 x 26 little squares (I chosen that amo... |
I would like to speed up pandas apply function. I have been using swifter . It currently takes about 5 mins for 200000 records using multiprocessing as below . Is there any way to speed this up further .
def partial_match(source_words, dest_words):
matched_words = ''
if any(word in dest_words for word in sourc... |
I have written an adapter for RecyclerView. It can handle onClicks for RecyclerView items and select the color name and edit TextView for the clicked item. By default the first item TextView name is the selected color.
When a user clicks another item the last item TextView is named black. When the the user clicks a col... |
Problem
For the given binary tree return the list which has sum of every paths in a tree. i.e Every path from root to leaf.
I've written following solution.
void check()
{
List<Integer> out = new ArrayList<>();
leafsum(root, 0, out);
System.out.println(out);
}
void leafsum(TreeNod... |
As part of an assignment for college summer classes, I was tasked with writing a program that solves roots of negative numbers. I've ran it through the test cases I was provided and it computes correctly. I'm looking for any feedback, especially about the determine_factors function, which really should be renamed. It l... |
I'm using Binance.Net and I wanted to get historical candle data from start date to end date which is useful for backtesting. They don't really provide that functionality, so I have to do it myself. Their API allows me to specify startTime (start date) and endTime (end date) and limit (cannot exceed 1000). I'm reading ... |
I need suggestions on improving this code, the code is working fine ,but i'm gonna deploy this to production system, so before that would like to ask the community for any improvements/suggestions.
The script insert/update MySQL database using the data from PostgreSQL DB.
I have tested with some sample values and both ... |
From HackerRank's 10 Days of JavaScript, Day2: Loops:
Complete the vowelsAndConsonants function in the editor below. It has one parameter, a string,s, consisting of lowercase English alphabetic letters (i.e., a through z). The function must do the following:
First, print each vowel in s on a new line. The English vowe... |
First of all, I am very new to programming and also this site.
This is a very simple "Rock, Paper, Scissors" game I made in C#. At first, it asks if I want to play the game. If my answer is yes, then I enter my name and the game starts. The program asks me to choose rock, paper or scissors, then the computer randomly p... |
I've recently finished my first ever C program. I implemented a Sudoku solver that uses backtracking.
Does my code look like a proper C-program? Are there any recommendations for improving my code?
#include <stdio.h>
int valid(int[][9], int, int, int);
int solve(int[][9]);
int find_empty_cell(int[][9], int *, int *);
... |
I have a class called IntMatrix which has 2 fields:
Dimensions dimensions;//To save height and width of my matrix
int *data;//For saving data
and I need to override the operators >,>=,<,<=,==,!= which take a scalar and compare each single value in my matrix with that scalar accordingly, and returns a new matrix with t... |
I want to share my raycasting source (the first engine:)
this program renders the game map (MAP array) and sprites (sprites_on_map array)
ask and criticize!
p.s I don't speak/write English very well (not my native language), but I tried to make the comments clear
This is data/wall_1.bmp
This is data/sprite_1.bmp
im... |
Task: Rowset of all reachable(in any direction) nodes from any node in a graph. In other words I need to extract all nodes of a particular graph from a table in the database where graph specified by an id of any one graph node. The final goal is a map in the app.
Table structure of DocumentDependency is simple as:
desc... |
Intro
I've been working to implement a modified version of the achemso.bst file from the American Chemical Society'sachemso package that properly implements patents as defined by the ACS Style Guide.
This is the first time that I've worked in a meaningful way with BibTeX Style files and while I am presently happy with ... |
I've created a code based upon a dice roll where the number of rolls is decided by user input. I am new to this, so any and all feedback will be appreciated as I feel the code is quite clunky at best.
number_of_times = int(input("How many times do you want to roll the dice?: "))
print(number_of_times)
def dice_roll(x)... |
I have a large log file in the following format. Do note that this is already sorted alphabetically. I wish to split it into smaller pieces, and with file names reflecting the content of the file (first three char of the row).
I wish for the code to be efficient. Speed and simplicity is the key. The log file is in 10s ... |
Following the method suggested here, I've written a Python script that generates random points along the perimeter of an ellipse. I wanted to compare a "naive" method (which fails to produce an even distribution) with the correct method, which works like this:
Numerically compute P, the perimeter of the ellipse.
Pick ... |
I wrote this code for finding, substituting and executing values in dictionary, much like $() bash operator works.
I used nested functions for this, forming hierarchy and encapsulating their names.
But now I'm concern, that this may be an overhead in reading ease and unit testing now
sucks, because I can't write test f... |
I am fairly new to Golang and I was creating an API to fetch commits from any Github repository using their API. I was then creating a frequency count, based on the date and then sending it to the frontend.
Added a Gist for a better view:
https://gist.github.com/karansinghgit/256a3f69698004cab4024c39767a0be1
Currently... |
I'm new to web development, and currently learning the basics of HTML and CSS. Many web pages follow the structural pattern of header, main, and footer; so I figured it'd be a good idea to try and implement this structure to see how things are carved.
body {
display: flex;
flex-direction: column;
font-family: s... |
Motivation
The most common model for a random graph is the Erdős–Rényi model. However, it does not guarantee the connectedness of the graph. Instead, let's consider the following algorithm (in python-style pseudocode) for generating a random connected graph with \$n\$ nodes:
g = empty graph
g.add_nodes_from(range(n))
... |
I wanted to build a scaping-API for the website 1001tracklists.com by writing classes for Tracklist and Track objects and some helpful functions:
Here's the full code (GitHub):
import requests
import re
from fake_headers import Headers
from bs4 import BeautifulSoup
SOURCES = {
"1": "beatport",
"2": "apple",
... |
I tried my hands on Rock-Paper-Scissors. But the twist is that the game has a brain that aims to learns your behaviour.
The brain is a simple counter that updates the player's current choice based on players previous choices. The level determines the number of previous choices cpu will remember. In any event the player... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.