instruction stringlengths 71 95.1k |
|---|
Problem statement:
Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, Celsius, Fahrenheit, Rankine, Delisle, Newton, Rømer, Réaumur.
Synopsis: tempconv INPUT_SCALE OUTPUT_SCALE [TEMPERATURE]...... |
Problem statement:
Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, Celsius, Fahrenheit, Rankine, Delisle, Newton, Rømer, Réaumur.
Synopsis: tempconv INPUT_SCALE OUTPUT_SCALE [TEMPERATURE]...... |
Problem statement:
Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, Celsius, Fahrenheit, Rankine, Delisle, Newton, Rømer, Réaumur.
Synopsis: tempconv INPUT_SCALE OUTPUT_SCALE [TEMPERATURE]...... |
Problem statement:
Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, Celsius, Fahrenheit, Rankine, Delisle, Newton, Rømer, Réaumur.
Synopsis: tempconv INPUT_SCALE OUTPUT_SCALE [TEMPERATURE]...... |
Problem statement:
Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, Celsius, Fahrenheit, Rankine, Delisle, Newton, Rømer, Réaumur.
Synopsis: tempconv INPUT_SCALE OUTPUT_SCALE [TEMPERATURE]...... |
Problem statement:
Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, Celsius, Fahrenheit, Rankine, Delisle, Newton, Rømer, Réaumur.
Synopsis: tempconv INPUT_SCALE OUTPUT_SCALE [TEMPERATURE]...... |
It's a very simple class to get a different proxy each time it's called. I've done it because I was trying to use aiohttp_scraper and it didn't work so I have to make my own. This is just one of the pieces.
class Proxies:
def __init__(self):
self.proxies = self.download_proxies()
self.proxy_pool = i... |
I have made a Java Swing application that detects and displays audio pitch and level from an input (e.g microphone). I would like feedback on the current structure of my project, I'm attempting to follow the modified MVC pattern found here, diagram of my project below:
I'm seeking feedback on the structure and any oth... |
Can I code this Simple Calculator in a more efficient way?
I'm currently self-taught, one thing I notice is that I get an error if I don't press the space bar after each entry, is there a way to avoid that error?
x,y,z = input(" Enter Your Math Problem ").split()
x = int(x)
y = str(y)
z = int(z)
if y == "+":
answ... |
SQL Server 2017
The table contains duplicate contracts per factory with different From and To dates.
I'd like to select the correct row based on a declared YearMonth parameter.
If this falls in the range between From and To date this row should be selected otherwise the fallback row with the default date 199401 should ... |
When creating a new Blazor project, there is a page called FetchData which gives an example of a razor page using a service to pull data to a page.
I set myself a challenge to improve on the service, so that instead of a random label being assigned to a temperature for a forecast, it separates the label categories even... |
This is my first attempt at writing a "large program", and I think that I've got the foundations for the emulator down. However, as I'm still a beginner, I might have made some questionable design choices (too many functions/too verbose/inefficient and so on), so I'd like to know if I can make the code more readable a... |
I am cleaning a dataset where columns lat and long are presenting some values multiplied by 10. Not only 10, but changing 10^n. I wrote the code below. I am not sure if it is the best way, but is working. May you help me?
I will put this code inside a function, so do not bother you creating a function at all. I just ne... |
I want to transform this dict to CSV:
{
"California": ["San Fransisco", "Los Angeles","Oakland"],
"Texas": ["Dallas", "Houston", "Austin"],
"Florida": ["Miami", "Tampa"],
...
}
I want the following output:
California,San Fransisco
California,Los Angeles
California,Oakland
Texas,Dallas
Texas,Houston
Texas,Austi... |
I scripted a program in python to generate lottery numbers for user. There are two playing methods:
Lotto6aus49: User can choose any 6 numbers out of 49.
Eurojackpot: User can choose 5 numbers out of 50 and 2 numbers out of 12.
The script will generate some random numbers with above condition and generate a text file... |
This is a follow up to ReversibleList: a list that is "reversed" in O(1) time [1]. Thanks for the suggestions!
Any suggestions for improvements are welcome!
A ReversibleList, a, behaves like a normal list when a.reversed == False.
a.reverse() "reverses" the list in O(1) -- the list is not actually reversed. What's actu... |
I wrote a code to reset user password. I just want to ask if it is a good and secure way to do this? Can I make any improvements here?
I use send_password_resetting_message function to send an email with a link to reset password and when I go on this page I use there set_new_password to set new password using uidb64, t... |
This thread is a continue version of Find match words based on a list of words where I now have added Good word dictionary. What I am trying achieve here is that I want to check if a user has a given sentence of e.g. "hello world" - Then we want to see if the sentence contains good word and NOT any bad word. If that's ... |
I am practicing designing OOP projects. And this is my first OOP design.
I need some reviews for the code and the design please.
Here is what they call UML.
The code.
import java.util.HashMap;
public class Library {
private static HashMap<Book, Boolean> store = new HashMap<Book, Boolean>();
public static Hash... |
Question Link.
Binary Search and Two Pointers related question.
For the above-mentioned question, In other people's solutions, people get AC with a binary search solution. However, I get TLE with Binary Search Solution. There might be some error in implementation and there aren't any Wrong Answers, so I can't figure o... |
Problem: Stacks can be used to check whether the given expression has balanced symbols. This algorithm is very useful in compilers. Each time the parser reads one character at a time. If the character is an opening delimiter such as (, {, or [- then it is written to the stack. When a closing delimiter is encountered li... |
I just started learning Rust, and try to implement a function like Django's get_or_create.
Now my implementation looks too verbose[ I hope that rust can be neater.
Therefore, how can I implement this function in less verbose way?
There is probably a way to shorten nested match constructions below?
use log::warn;
use d... |
I have designed a class bunji::Tensor which is a multi-dimensional array. I have designed it to have a similar interface to a multi-dimensional std::vector, just that the bunji::Tensor constructor takes in an std::vector in its constructor which defines the dimensions, i.e.
bunji::Tensor<double, 3> my_tensor({10, 4, 2}... |
I made a simple Patience/Solitaire card game. The cards don't use images but JLabels and JPanels. The game is finished when all cards are on their suit piles.
Card movement:
mousePressed : card -> TOP (suit pile).
mouseDragged : card(s) -> COLUMN.
I would like some feedback on my code.
package patience;
import java.... |
Intro
Having spent quite a bit of time learning Python, I thought it was time to work on something. However, an Google search for "python projects 2022" came up with projects I had already completed.
Looking through my projects, however, I came across this. (link). I decided to test my abilities and rewrote the code.
P... |
For almost the past year, I have been working on a pixel art editor for Android.
My pixel art editor was relying on an external library for its color picker. For 0.2.0, I wanted to change this by working on my own color picker.
This was quite a challenging task, but I got it done in the end.
Here were my objectives for... |
Please look at the Java Stream methods in the for each loop.
This method totals the score for when the your desired team is playing during the football season - input param teamKey - it is either team1 or team2
I extract score1 or score2, which I total from the Json. The Season object contains, collections of collectio... |
MY CODE:
import time
import math
import sys
def sums(n):
r = 0
while n:
r, n = r + n % 10, n // 10
return r
def f(n):
r=0
s1=0
while n:
r, n = n % 10, n // 10
s1=s1+math.factorial(int(r))
return s1
def sf(n):
return sums(f(n))
def g(i):
p=1
while True:
... |
I have completed the Hangman game. Can somebody look at the code and see what I've done wrong? What should I add to improve it? Are there any bugs in it?
import random
word_list = ['sleep','window']
get_word = random.randint(0,len(word_list)-1)
get_word = word_list[get_word]
result = ["_"] * len(get_word)
x = "_"... |
I'm solving "Unknown amount of duplicates. One missing number.":
In this kata, we have an unsorted sequence of consecutive numbers from a to b, such that a < b always (remember a, is the minimum, and b the maximum value).
They were introduced an unknown amount of duplicates in this sequence and we know that there is a... |
I've learned Python basics about two years ago and did a few personal projects, one big one that turned out to be useful in my line of work, a few small programs for my hobbies and I've also began working on this huge personal project that is currently in a state of crisis as it needs a complete reworking to fully supp... |
I have a very simple API query (using GraphQL - URQL, but the client used doesn't matter) that just fetches data and displays it on the page, and I’m trying to figure out the most efficient way to make the query not re-run whenever the component re-renders (which I assume it possibly does).
According to the URQL docs' ... |
I am writing a function that takes an array and an integer number and returns an array of all the partitions into subarrays (so an array of arrays of subarrays). The number of subarrays is exact the integer number passed to the function. And the subarrays have to be continuous, meaning the original order of items in th... |
The VisitedCollection is a collection wrapper for setting and tracking if elements were visited (removed in terms of the wrapper)
I have concerns regarding:
should equals and hashCode throw ConcurrentModificationException is underlying collection is changed
is it ok that visiting is performed by Iterator.remove() meth... |
My friend and I were trying to reproduce Figure 4(left), page 7, from the paper "Probing phase structure of black holes with Lyapunov exponents", Guo 2022. We succeeded in reproducing the result after writing a lengthy and complicated code. Here I dissect the code in steps:
Step 1:
Find the parametric plot for Free Ene... |
Here is the plan:
a slab takes up 1 page and it has PGSIZE / blocksize amount of blocks
the minimum blocksize is 8 bytes, otherwise the pointer to the next block will get overwritten
when a block is allocated, the free block is removed from the linked list
when a block is freed, it is added back to the slab's free blo... |
I want to remove leading zeroes (for a big integer library I'm currently making) in numbers represented as char arrays.
I chose assembly for speed, but in order to simplify making the algorithm and all, I decided to write it in C first. Here's the algorithm, written in C.
void remove_leading_zeroes(char *number) {
ch... |
Greeting to all senior devs here. I'm trying to create a project for my small business. There are not many tutorial on how to create Reactive JWT authentication with Spring webflux. So I'm a bit scared if I make any vulnerabilities. If you could help me review this project I would be grateful. So let's get started.
Sec... |
I have transaction tables called MaterialRequest and MaterialRequestDetails.
What I want to check my query and review that it's correct way to do this.
Below are tables
CREATE TABLE [dbo].[Unit](
[UnitNo] [int] IDENTITY(1,1) NOT NULL,
[Unit] [nvarchar](50) NULL,
CONSTRAINT [PK_Unit] PRIMARY KEY CLUSTERED
(
... |
I'm trying to build a function to return an Iterator with no duplicated float values, its working, but there is a better way of handling this duplicated values?
from collections import deque
from collections.abc import Iterator
from locale import atof
def get_non_repeated_numbers(n: int) -> Iterator[float]:
"""
... |
Let me start by stating that I am currently in the process of learning Go and AWS CDK. What better way to learn than building a Serverless Todo API!? Using the Go AWS CDK (v2) I have built my infrastructure using the following AWS components:
API Gateway (HTTP)
AWS Lambda (Go)
DynamoDB
All code is open-source. It is ... |
What do you suggest to make this code faster? This code gets all possible combinations of actions for a certain number of stocks in pairs in the format [action, volume]. One action element would be something like [[action1,volume1],[action2,volume2],[action3,volume3]] where the actions are either 0 (i.e. Sell) or 1 (i.... |
I wrote a code to remove the background of 8000 images but that whole code is taking approximately 8 hours to give the result.
How to improve its time complexity? As I have to work on a larger dataset in the future.
from rembg import remove
import cv2
import glob
for img in glob.glob('../images/*.jpg'):
a = img.spli... |
I've been working on an intrusive linked list for the past few days for a personal project and I would like to have some feedback on it. :)
Personally, I would have preferred to make List and ListNode opaque. However, (I may be wrong here) that means I can only use pointers to them which would mean I have to use ListNo... |
I have a linked list code in C++:
#include <string>
#include <iostream>
using namespace std;
class Node
{
public:
string name;
int age;
Node *next;
Node(string name, int age)
{
this->name = name;
this->age = age;
this->next = nullptr;
}
};
class List
{
private:
Nod... |
I am solving this problem where the function returns the number of times a pattern is found in a said string word. It could be easily solved via std::find but I wanted to implement the logic myself and see if I bring in some improvements but turns out my solution fares worst than with std::find.
The solution works but ... |
I have a list of binary strings where each binary string max length is 15. I need to find list of integers which is count of similar (should differ by max 1 bit position) binary strings present in the list for each of the binary strings present in the list. This is current solution with time complexity of O(N²) but get... |
I have a bunch of checkboxes with a data-amount attribute containing a value (positive or negative).
My goal is to generate a running total as the user checks each box, and then output this later on.
My code works - just curious for feedback as using filter, map and reduce seems overkill for something like this.
Thanks... |
This is a continuation of Goat racing up a hill (C++ hiring take-home) . This is an interview take-home challenge that has been translated to avoid compromising the company's question.
Problem statement
You are a goat that needs to race up a hill. Designated waypoint rocks on the hill must each be visited in sequence (... |
I was trying to implement a boolean that can be atomically flipped.
The suggestion on Stack Overflow is to use an integer.
This would be my implementation.
#include <atomic>
#include <iostream>
class flippable_atomic_bool {
std::atomic<int> state;
public:
flippable_atomic_bool() : state(0){}
explicit ... |
I wrote some code that will get the name and data of a node or multiple of nodes and put them in an object (seriesData) so I can use said object for a chart (renderChart). I used setTimeout() so seriesData can populate before rendering the chart.
Everything works as intended. Is there a better pattern to handle this? I... |
Here is an input array that contains country name, year and value. I need to group values by country and years.
I use this approach that works for me, but I wonder how to optimize it:
export function collect(
data: any[],
years: string[] = ['2020', '2021', '2022', '2023', '2024']
) {
const countries = new Map<str... |
I'm coding with c++. Basically the question is about to make calculation of any product and calculate with price and quantity with our name. Anyone can simplify this coding?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string star = "******************************************************... |
Recently I implemented a python code that predicts the next number of a sequence using a difference table (a little more on the subject here)
def s(d,p=0):
if (len(d) > 1):
return s([i[0]-i[1] for i in zip(d[1:], d[:-1])],p+d[-1])
return p+d[-1]
print(s(list(map(int, input().split(",")))))
This code t... |
Re-posting from StackOverflow as this is a place to review code that is already working.
I would like to know if there is a better way to deal with nested forEach when it comes to dealing with objects with properties that are nested arrays themselves.
My object (summarized):
{
...,
"tx_responses": [
{
...
... |
I made classes to use in generating square/rectangular shapes on a texture.
import numpy as np
import random
class Tex_SHR:
def __init__(self, resolution: set, colorGrade:str, genNum: int, genOption: int):
self.resolution = resolution
self.colorGrade = colorGrade #Not yet in... |
I've written a small script for Zabbix to check the status of our ESXi Hosts. The request needs to be authenticated, so I went for this process:
Read auth token from file
If file does not exist, authenticate and store token into file
Run request to get the information
If I get permission denied, authenticate, stor... |
I'm building a game interface that has the following user flow:
The user lands on one of the game's URLs (eg. www.name.com/game1), first gets an "intro" screen, then the game screen, and finally a fail or success screen.
I'm trying to figure out the most optimal way to do this. Below is the code that works just fine, b... |
This is my code for the CS50 Mario (more comfortable).
Answers can be found all over the net however I wrote this myself.
I would like to refactor to its maximum potential (just for my own improvement I'm not enrolled or anything).
A quick outline of the code:
Firstly it asks for a valid input of an amount of rows to b... |
On RosettaCode I found this C++ version of modPow (compute 2ᵖ mod n) to find the factors of a Mersenne number.
#include <iostream>
#include <cstdint>
typedef uint64_t integer;
integer bit_count(integer n) {
integer count = 0;
for (; n > 0; count++)
n >>= 1;
return count;
}
integer mod_pow(intege... |
Is there a possibility to refactor this method and make it clean and respect solid principles.
public String pickOne(int input) {
if ((input % 3) == 0 && (input % 5) == 0)
return "fizzbuzz";
else if ((input % 3) == 0)
return "fizz";
else if((input % 5) == 0)
... |
Below my first code in c++. Its running fine. I feel I could improve a few things in my code. Please feel free to comment
#include <iostream>
#include <ctime>
#include "windows.h"
using namespace std;
class BattleShips {
public:
static const int rows = 2;
static const int elements = 2;
in... |
I faced this exercise.
Given a sequence \$S\$ (\$2 <= |S| <= 10^6\$) of numbers (\$1 <= S_x <= 10^7\$), determine \$max(abs(S_i - S_j) + abs(i -j))\$.
Here is the solution I found:
int main(){
ios::sync_with_stdio(false);
int N;
cin >> N;
vector<int> S(N);
for(int i = 0; i < N; i++) {
cin >>... |
This is an attempt at a multithreaded model-view-controller based engine for 2d console games (board games, roguelikes that sort of thing.) The code below will provide a fully working example but is missing a lot of bits as I am specifically interested in a critique of the multithreading and MVC bits though any other ... |
I recently built my first web scraper in python, and decided to use SO and SE as test websites.
Code
# import selenium
!pip install selenium
!apt-get update # to update ubuntu to correctly run apt install
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
import sys
import os
sys.pat... |
Objective
I have a 3D face mesh triangulated. I have computed the midpoint of each triangle in the mesh, and I have the normal vector (n1, n2,n3) for each triangle. The objective is to create a 2D grid with [width x Height] resembling an image (with z assumed to be a constant). This is placed on top of the face mesh.
R... |
I've been searching through the different ways to store data and found some helpful and actually great libs like:
JSON
XML
And some neh:
text file basic write and read
some binary type data storing?
some other database types...
Yet still I didn't find an easy and light library with basic storing mechanism/way (In m... |
I would like to learn Python and (maybe...) someday become a developer. Nevertheless... I've written a small "Rock, Paper, Scissors" game.
Can you please take a look at the code and write the feedback? All types of feedback is highly appreciated!
import random
from enum import Enum
class Hand(Enum):
ROCK = 1
... |
I have written this code to perform vector operations like addition, multiplications and so on. I was wondering if there is a better way to write this code? Because I feel it is a little bit repeated.
class VecError(Exception):
pass
class vector(ABC):
@abstractmethod
def __init__(self, vector) -> None:
... |
I wrote a piece of blackjack code - for dealer dealing cards to himself (python). My question is how can I make it more efficient, faster and neater. I ran it for 1.000.000 iterations and it took 14.7 second which is quite slow, I believe.
import random
deck = 4 * [2,3,4,5,6,7,8,9,10,10,10,10,11]
random.shuffle(deck)
... |
I am getting started with rust. To get familiar with the language I implemented a datetime library:
main.rs
mod datetime;
use datetime::DateTime;
use datetime::Date;
use datetime::Time;
fn main() {
let date_time = DateTime::create(2022u16, 09, 17, 02, 53, 00);
println!("Datetime: {}", date_time);
println!... |
I have been learning C with K&R Book 2nd Ed. And well, so far I've gotten to chapter five, and I've been dealing with pointers/command line arguments.
I came up with the following solution for the exercise (Chapter 5, Ex-5.10):
Exercise 5-10. Write the program expr, which evaluates a reverse
Polish expression from the... |
I have designed a Hit Counter which can conveniently be used to design a Rate Limiter
Original question: https://leetcode.com/problems/design-hit-counter/
To make it thread safe, I used lock statement.
public class HitCounter {
private readonly int duration = 300;
private readonly int[] hits, times;
//https://doc... |
I've finally come up with working solution for day 12 of AdventOfCode, where you have to find the number of possible paths in a cave system following a given set of rules (described below). My solution seems a bit messy. I include an iterator class that employs recursive call of the same iterator. I'd be very grateful... |
I got the idea for this code from an article on converting ZX81 BASIC to Pygame. Although some code was provided in the article, I implemented this myself.
I'm pretty dubious about the approach of using nested for loops inside the main game loop to make the game work, but at the same time I'm curios to see how well the... |
Solving the following problem on Protohackers: https://protohackers.com/problem/1
The problem:
Each request is a single line containing a JSON object, terminated by a newline character ('\n', or ASCII 10). Each request begets a response, which is also a single line containing a JSON object, terminated by a newline cha... |
I have a very simple method that returns a tuple of integers in a list that sum to a specific target sum. The method works as expected, however, with a large list, it is slow. I have looked for articles about optimizing for loops, but I have not found anything that makes sense or helps in the case. Is there a "standard... |
I wanted to know whether this approach is correct or not for a basic quiz game. I have not used object oriented programming style, Defining the quiz questions as array elements and looping through the array with a variable.
let q = ["1. What is the capital of Israel ?",
"2. Who is the Prime Minister of India?",
"3... |
Today I was challenged to build atop Python's logging module to automatically log the filepath from whence the log statement was issued.
The guidance in the https://docs.python.org/3/howto/logging.html#advanced-logging-tutorial is to logger = logging.getLogger(__name__) atop each module.
The question was: "Can I clean... |
I have this typical code interview type problem.
Suppose you have a stick of length n. You make X cuts in the stick at places x1, x2, x3 and so on. For every cut in X cuts you need to print the length of current longest piece.
Here is my current code:
def get_index_binary_search(list_thing,index, j):
start = 0
... |
I wrote an implementation of the MD5 hashing algorithm from scratch in C++, following the original RFC: https://www.ietf.org/rfc/rfc1321.txt . It works as expected, and the outputs match all the test cases mentioned in the RFC as well. I timed this for a couple of test cases, and it seems it takes around 0.25 msecs on ... |
This script creates a hamburger menu when the window is resized. It will also create a sticky navigation when the window is scrolled down, which will also create a hamburger menu when the window is resized.
I'm looking for advice on how I can best structure the Javascript in my code.
// When the user scrolls the page... |
Description
Splits a string into a vector of strings that has consecutive same characters
Examples in test cases below ("5500025" --> ["55", "000", "2", "5"])
Only ASCII needs to be supported
In case of style/formatting issues, I am using https://zed0.co.uk/clang-format-configurator/
Compile
gcc -std=c++17 file.c... |
I would like to create a matrix of delay from a time series.
For example, given
y = [y_0, y_1, y_2, ..., y_N] and W = 5
I need to create this matrix:
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 | y_0 |
| 0 | 0 | 0 | y_0 | y_1 |
| ... | | ... |
I state that I am not an expert and that certainly the code can be improved.
I made this prime number sieve to be able to handle large numbers.
The basic idea is to write a number p=r+bW*k where r is the remainder of p divided by bW and bW the modulus. In practice it is a wheel sieve where multiples of the prime number... |
I wrote a simple string pool for my compiler in C++ and want to hear your thoughts on its design.
String pool has 2 functions: intern and internLiteral. The only difference is that after interning literal, its memory is used. So no allocation happens. If memory for the same string was already allocated, it will be deal... |
I am trying to sort an array of associative arrays in reverse order by the key of the subarrays.
I solved it with a bubble sort algorithm which worked just fine in my test.
I was wondering if there is a better way, maybe a standard PHP method which I am not aware of.
$list = array(
array(0 => "F"),
array(1 => "... |
I am trying to write a utility for transforming xml trees using single pass and specifying node handlers.
I used pugixml prior to this, and the library provides a rather convenient API to traverse child nodes based on XPath strings.
However, I don't quite like the idea of multiple invocations because it means traversin... |
The project outline:
Create a Mad Libs program that reads in text files and lets the user
add their own text anywhere the word ADJECTIVE, NOUN, ADVERB, or VERB
appears in the text file. For example, a text file may look like this:
The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN
was unaffected by th... |
I use a lot of for loops and I think it slows the code down a lot but I have no idea how else this code could be written. Its for a to-do list app and each for loop adds an eventListener to each button on each task (edit, delete, check).
Is there a more efficient way to write this?
import {myTasks,newTaskForm,rightSide... |
What my program does
I'm trying to estimate for how many minutes in average a football(soccer) match will be in different game states depending on implied goals of both teams.
Problem domain
For our purposes there are three possible game states:
Home team is ahead, e.g. 1-0
Both teams are drawing, e.g. 2-2
Away team i... |
I am newbie in the field of programming, but I have tried to make relatively "huge" project. My "app" would derivate a mathematical expression, after that simplify the output expression.
How could I improve the expression simplify function to further simplify the output expression?
I know about simpy, I want to impleme... |
the aim of the code below is to print all balanced sequences with equal number of 'A' and 'B'. A sequence is balanced if every prefix of length \$\geqslant 4\$ is balanced. A prefix is balanced if the ratio of 'A' in this prefix is between 0.4 and 0.6 inclusive.
For example, ['A', 'B', 'B', 'A', 'A', 'B', 'A', 'B'] is ... |
The project outline:
Write a program that opens all .txt files in a folder and searches for
any line that matches a user-supplied regular expression. The results
should be printed to the screen.
My solution:
import os, re
from pathlib import Path
while True:
user_path = input("Enter a path to search: ")
if u... |
I've a table in HTML looks like this:
Subjects
n1
n2
n3
subject1
10
0
0
subject2
0
5
20
<table>
<thead>
<tr>
<th class="subject">Subjects</th>
<th>n1</th>
<th>n2</th>
<th>n3</th>
</tr>
</thead>
<tbody>
<tr>
<th class="subject">subject... |
This was a homework assignment for a data structures course. The goal was to implement a given interface and the assignment was auto-graded by a system that ran some validation tests. Sadly I did not really get any feed back on the code structure or any advice on how to improve on what I did if anything was wrong or no... |
I'm learning how to reverse list and strings. Is there another way of reversing a string other than using [::-1] method? even if the other method is the long route i would much appreciate it
txt = ["Hello World"]
st ="".join(txt)
print(st[::-1])
|
I am writing an observer design pattern that is not too complex but I still feel there's a lot for me to learn about C++ be it little details (especially coming from C).
A couple of observations:
I wanted to understand was Subject here isn't an abstract
class unlike Observer however I would ideally have caller
instant... |
This is some assembly code I've written to add two base-10 numbers. The input and output are represented as null-terminated ASCII strings, with digits in big-endian order.
I have also provided comments for each line explaining what it does. Is there anywhere I can use SIMD or something which will be faster here?
Since... |
This is my 1st time developing PHP code and I am only 13 years old. I have experience in other programming languages like lua, python, and c++.
This is a simple Number to Roman Numeral code I made for my mom because she had a hard time making herself one. Below is my code. Don't mind the names of the variables.
<?php
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.