[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

[Advertise on 4chan]


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


What are you working on, /g/?

Prev: >>82009137
>>
File: 1622811430807.jpg (11 KB, 285x285)
11 KB
11 KB JPG
Alright, since you're all NEETs who have nothing better to do than argue - chew on this. Language of your choice, cleverest solution wins.
Yes, it's Leetcode.
Yes, you should be ashamed if you can't do it without googling.

A password is considered strong if the below conditions are all met:
>It has at least 6 characters and at most 20 characters.
>It contains at least one lowercase letter, at least one uppercase letter, and at least one digit.
>It does not contain three repeating characters in a row (i.e., "...aaa..." is weak, but "...aa...a..." is strong, assuming other conditions are met).
Given a string password, return the minimum number of steps required to make password strong. if password is already strong, return 0.
In one step, you can:
>Insert one character to password,
>Delete one character from password, or
>Replace one character of password with another character.
Example 1:
>Input: password = "a"
>Output: 5
Example 2:
>Input: password = "aA1"
>Output: 3
Example 3:
>Input: password = "1337C0d3"
>Output: 0
Constraints:
>1 <= password.length <= 50
>password consists of letters, digits, dot '.' or exclamation mark '!'.
>>
is it too late to get into programming at 18?
>>
Three cheers for C#! Fucking hell, I regret listening to you idiots and keeping away from that beauty.
>>
in c++, does declaring an object run the constructor?
>>
>>82022395
no, I had 0 programming experience before university and now make a decent living from it.
>>
>>82022395
According to HR you should already have 25 years of experience of the technology that comes out next year.
>>
>>82022413
yes, namely the default one
>>
working on a new programming language better than Rust
>>
>>82022447
What feature are you working on for C++23?
>>
>>82022447
already have the homepage, logo, and compiler uploaded!
https://crystal-lang.org/
>>
>>82022393
>cleverest solution wins.
stopped reading there
>>
>>82022319
cross compiling from linux to windows so i wont have to expose my source code to that pozzed OS
>>
>>82022393
next time, if you want to bait /dpt/ into a pissing contest, you need to post a solution + a condescending remark about its language's superiority.
>>
>>82022507
then do it however the fuck you want, loser.
>>
>>82022413
>>82022436
what? you declare variables and classes, you don't declare objects.
>>
File: 1618028557022s.jpg (6 KB, 250x230)
6 KB
6 KB JPG
>>82022483
>>
File: 1615925658917.png (7 KB, 223x226)
7 KB
7 KB PNG
i am new to programming and was trying to build a website price tracker ( eg: amazon ). What is the difference between using official APIs ( need to pay for aws? ) and using beautiful soup or some parser to parse items based on an ID?

will only be parsing about 50 items each day. how do I know if using external parsers 50 times will trigger bot detection? Will it trigger bot detection. i am confused
>>
>>82022543
I assume he meant something like which is not really 'declaring' but looks similar to it.
>>
File: firefox_etM1uWzzZ3.png (17 KB, 521x472)
17 KB
17 KB PNG
>>82022624
>>
>>82022575
better off asking >>82015881 , no one here is smart enough to do web dev.
>>
>>82022543
Eh, you can declare a pointer to an object. Close enough.
>>
>>82022219
>An instance of a class is as big as the sum of all its members, right?
Wrong. Take as example
class A
{
int a;
int b;
bool c;
bool d;
}

class B
{
int a;
bool b;
int c;
bool d;
}

A and B will have different size.
>if I instance a class that doesn't have members, only methods, how big would that be
In most cases, it will be 1 byte of padding, because c++ doesn't allow empty objects. The only exception is inheritance from empty class - in that case it will be really empty.
>>
Is there any great guides for c# + Java like there is for drawing (drawabox)?
>>
>>82022447
Ugh. May I ask its general features?

What I *reeeaaalllllyyyyy* want is a better language than Python.
>modern statically checked type system, fuck mypy, that's nigger shit
>native execution
>still embeddable
>keep instrumented language features by introducing metaprogramming using the same syntax as runtime language
>multiple dispatch
>Lua-esque multi-stack coroutine system with opportunistically multithreaded symetric coroutines, fuck async/await and asyncio, that's nigger shit
>FFI-based C interop, not gayass ctypes or C API
>better build, packing, and environment management solution that can build and package foreign objects like C shared libraries
>>
>>82022411
based
>>
>>82022880
if python had strong typing, non-mandatory indentation, enforced semi-colons, and was basically a wrapper over C it would literally be the perfect language.
>>
>>82022393
Something like this, didn't test it much.
int password_check(std::string_view password)
{
assert(password.size() >= 1 && password.size() <= 50);
char curr = ' ';
int cnt = 0;
std::vector<int> repeats;
bool lCase = false,
uCase = false,
digit = false;
for (const auto c : password)
{
if (islower(c))
lCase = true;
if (isupper(c))
uCase = true;
if (isdigit(c))
digit = true;
if (c == curr)
{
++cnt;
}
else
{
if (cnt > 3)
repeats.push_back(cnt);
cnt = 0;
curr = c;
}
}
int ret = (!lCase + !uCase + !digit);
int rep = 0;
for (const auto i : repeats)
rep += i / 4;
ret = std::max(ret, rep);
if (password.size() < 6)
{
ret = std::max<int>(ret, 6 - password.size());
}
else if (password.size() > 20)
{
ret += password.size() - 20;
}
return ret;
}
>>
>>82022632

just wanted to thank this anon for the homework help
>>
File: screenshot_1.png (30 KB, 802x632)
30 KB
30 KB PNG
plsnodox
Roast my code for my tetris game (:
https://github.com/geocase/tetris
>>
>>82023243
passes the regular cases, but it doesn't seem to handle three characters in a row well (e.g. "Paaasword123" returns 0 when it should return 1). Also:
"aaa123" - should be 2, got 1
"aaa111" - should be 2, got 1
>>
>>82023361
tetris_Update(struct Tetris* to_update, /*hack*/ struct AudioPlayer ap, float game_time) {

Did you think no one would see this, huh punk?
>>
>>82023450
oh my god, the rotation code
>>
>>82023365
>it doesn't seem to handle three characters in a row well
oh, I made it trigger on 4+ characters.
What it also doesn't handle well is 20+ and multiple characters in a row, as you can sometimes get rid of both with 1 delete.
>>
>>82023361
isn't it better to have the frame rate independent via a delta-time multiplication?
>>
>>82023514
It depends.
https://gafferongames.com/post/fix_your_timestep/
I implemented a very lazy version of proper time stepping. In this very simple case that would be fine but in general you want physics simulation (or any kind of game simulation) to be somewhat deterministic.
>>
>>82023361
you should sent this in to Cherno and have him do a video on it
details here https://twitter.com/thecherno/status/1311233289114406913
>>
>>82023581
This is in C. He only mentions C++.
>>
>>82022319
>haskell
>stateless
found the mentally ill
>>
>>82023601
he'd probably still do it since it's opengl stuff. the submissions i've seen videos on are hardly idiomatic c++ by any stretch of the imagination.
>>
>>82023479
1 turn to the left: transpose(map(reverse matrix))
1 turn to the right: map(reverse,transpose(matrix))


void swap(int* x, int* y){
x ^= y;
y ^= x;
x ^= y;
}

void reverse (int * line){
for(i=0; i<=2; i++){
swap (line[i],line[3-i]);
swap(line[3-i],line[i]);
swap(line[i],line[3-i]);
}

void map ( void (*fun) (int*), int* matrix ){
for(i=0;i<4;i++){
fun(matrix[i]);
}
}

void transpose(int **matrix){

for(i=0;i<4;i++){
for(j=i;j<4;j++){
swap(matrix[x][y],matrix[y][x];
}
}

}



or something like that, just wrote it in here, didn't bother to check if compiles.
>>
File: rolldice.webm (110 KB, 708x428)
110 KB
110 KB WEBM
Working on an online multiplayer monopoly rip off.
>>
>>82022319
data wrangling with awk, sed, grep, coreutils etc.
>>
>>82023676
>functional programming in C

Dangerously based
>>
>>82022393
>Password isn't strong if it's more than 20 characters
>>
>>82023676
If I'm counting it right that's 22 swaps per rotation rather than at maximum 12 for a counter clockwise rotation or maximum 36 for a clockwise rotation, which is only a 1 in 7 case for the I tetrimino, as the other 6 pieces only use a 3x3 matrix (within a 4x4 matrix, thus the "edge" var defined) thus only requiring 6 swaps for counter clockwise, and 24 for clockwise.
I'll keep what you posted in mind for other matrix rotational stuff in the future.
>>
>>82023774
>number of steps required to make a password strong is remotely useful information
>the year isn't >2000 and you need more than a cursory complexity requirement on your way to an actually useful solution of using the haveibeenpwned API to forbid password reuse
>>
>year of our lord and savior
>user generated passwords
>>
>>82023774
'strong' is obviously relative to the problem description. it's not meant to be a realistic definition, merely one to constrain the programmer to the task at hand.
>>
>>82023789
implement something once, reuse forever.
>>
i don't really like programming anymore and i don't know what to work on
>>
>>82023969
work on stretching your ass hole out
>>
>>82023973
buck please
>>
>static checking make C/C++ as safe as safe languages
What static code analyzer do you use, anons?
>>
>>82024034
ada
>>
>>82024034
borrowck
>>
>>82024034
My brian (:<
>>
>>82024034
>>static checking make C/C++ as safe as safe languages
lol no
>>
File: 1385077398214.jpg (44 KB, 261x287)
44 KB
44 KB JPG
Is there any reason I should use a format besides JSON for persistent configuration files? I don't expect to store anything too complicated. Maybe a couple arrays of strings. Maybe nested would be useful but probably not necessary.

I see people using YAML sometimes, but wondered what opinions people have.
>>
>>82024293
you could always use xml if you're working with really old software
sometimes .config files are just line separated, so each line is a different config option

in most cases you should probably just use json or yaml like a normal person
>>
File: 1622933951601.jpg (83 KB, 720x720)
83 KB
83 KB JPG
>>82022319
>communism/socialism
>stateless
That's an oxymoron. Stateless would be anarcho-capitalisms. Fucking cringe.
>>
>>82022319
>What are you working on, /g/?
It's 12 noon and I'm still at that stage of deciding what projects I'll be doing today.
shitposting on /v/ doesn't look interesting right now and I don't feel quite like coding today.
the future looks dim.

>>82024293
json is good where a flat config file would otherwise be used, otherwise it can be difficult to extend without breaking backcompat.
xml is easier to extend because data is enshrouded with its data type, although it is more verbose and you will likely want to use a library for it.
>>
holy shit i dont think i wanna learn rust anymore
>no decent gui bindings
>shit for game dev

is it just a meme? i really don't wanna deal with garbage collection in 2021 but relearning c++ seems like the wiser choice against this beta shit that might never amount to anything
>>
>>82025207
https://github.com/BindBC/bindbc-glfw
>>
>>82025207
not all languages are for all applications. Rust was designed for system programming, where you want very strong guarantees that it is free of certain common classes of bugs, many of them regarding memory access
>>
>>82025383
what a hollow reply and rationale.
It's basically
>yeah this language is kind of shit, but it can make more guarantees a bit easier, so what can you do?
At this point, just unironically use Ada if you need the strong safety. Atleast it's unapologetic and doesn't try to trick you about anything.
>>
>>82025428
>yeah this language is kind of shit,
you read it how you wanted. go write web software with C++ and then bitch about how it sucks at that job, or why your Python code is really slow when you try and use it for high frequency trading transactions.
>use Ada if you need the strong safety
I don't think you have a clue what the intent of Rust is, so why are you using it?
>>
>>82025457
>I don't think you have a clue what the intent of Rust is, so why are you using it?
lol, i'm not >>82025207
Ada was the original (but competent) Rust, but it got fucked over by bad decisions and C took over.
SPARK was and still is immensely ahead of Rust.
But what exactly is the *intent* of Rust then?
>>
>>82025500
>But what exactly is the *intent* of Rust then?
>>82025383
>Rust was designed for system programming, where you want very strong guarantees that it is free of certain common classes of bugs, many of them regarding memory access
if you try to do unsafe things you might in other languages your code won't even compile, like trying to access an object after it would have been freed
>>
>>82025546
>>Rust was designed for system programming, where you want very strong guarantees that it is free of certain common classes of bugs, many of them regarding memory access
that is literally ada, and it was extended with SPARK for even greater static analysis.
>>
>>82025562
then fucking go use Ada, what do you want? I don't know it very well, but I don't think I've ever heard it used outside of military/avionics type applications
>>
>>82025613
>accuse me of not "understanding" rust >>82025457
>get proven wrong
>get mad
classic
>>
File: 1623338648938.jpg (163 KB, 1200x1800)
163 KB
163 KB JPG
https://en.m.wikipedia.org/wiki/Database_index

why do we need to index when we have key value pairs in the index. arent databases accessed using keys? i am so confused. plz go easy. a bit low IQ
>>
>>82025623
>my opinion proves you wrong
ok buddy
>>
>>82024293
In c you can write a literal struct to a file. The first x bytes could be a struct with a single 64 bit integer identifying the version number or some other identifier so you know what struct the file represents. You can use iovec to painlessly read this header and then have iovec read the next x bytes into the correct struct. You could make this go on for as long as required until you hit eof.

https://man7.org/linux/man-pages/man2/readv.2.html
>>
>>82025627
> ndexes are used to quickly locate data without having to search every row in a database table every time a database table is accessed.
it's right fucking there
>>
>>82022447
Is that you, Jonathan?
>>
>>82025627
>arent databases accessed using keys?
they can be, but I think you're confusing a primary key with a key in a hash table. you can write a SQL query to find data by literally any column, it doesn't have to be a primary key. keys allow you to create and enforce relationships between tables.
indexes are a separate but related feature, and are typically used to help improve query times on tables. if the table doesn't have an index, it usually has to resort to table scans, which can be really slow on tables with large numbers of rows
>>
File: zig.jpg (76 KB, 1400x718)
76 KB
76 KB JPG
What color scheme is this?
>>
>>82025613
Nobody who recommends Ada on /g/ has ever used it. It's even more restrictive than Rust when it comes to memory management because it's intended for applications where you just don't do memory management very much if at all.

The real reason they compare Ada to Rust is because one was designed by the US military and one was designed by "Mozilla trannies". They're LARPers.
>>
>>82025500
>But what exactly is the *intent* of Rust then?
If you remember early days of single process Firefox where it leaks memory that you need to restart it after a few days, then you'll know why they invented Rust: it's meant for their junior engineers who are too incompetent to write C++ code that don't leak memory. How do you know that it's a dead meme language? Because Firefox never got rewritten completely in Rust. Mozilla shut down the entire Rust division, and dumped all of the trannies onto the Linux foundation.
>>
>>82025932
Memory safety has nothing to do with memory leaks.
>>
File: lmao.gif (2.91 MB, 480x270)
2.91 MB
2.91 MB GIF
>Memory safety has nothing to do with memory leaks.
>>
>>82025932
>we need a Go before Go
>hm lets make it arguably even more tedious and complicated than sepples
humans are a mystery
>>
>>82025984
Leaking memory is a safe operation. What is there to argue about?
>>
@82025984
It doesn't. "Each allocation shall eventually be freed" is a liveness property, not a safety property. Anyways, it's impossible to statically eliminate all memory leaks in a Turing-complete language, because it's common to end up in a scenario where an allocation will be freed if and only if a piece of code halts (which is what makes it a liveness property and not a safety property).
>>
/*
** Remove the first space-delimited token from a string and return
** a pointer to it. Add a NULL to the string to terminate the token.
** Make *zLeftOver point to the start of the next token.
*/
static char *GetFirstElement(char *zInput, char **zLeftOver){
char *zResult = 0;
if( zInput==0 ){
if( zLeftOver ) *zLeftOver = 0;
return 0;
}
while( isspace(*(unsigned char*)zInput) ){ zInput++; }
zResult = zInput;
while( *zInput && !isspace(*(unsigned char*)zInput) ){ zInput++; }
if( *zInput ){
*zInput = 0;
zInput++;
while( isspace(*(unsigned char*)zInput) ){ zInput++; }
}
if( zLeftOver ){ *zLeftOver = zInput; }
return zResult;
}

this is why C is for big brained people only
>>
>>82026057
even if you severely limit what the programmer can do with allocations?
Lets say every assignment will copy and you cannot take an address to an object
>>
>>82026161
if you ignore all the casts it makes perfect sense
>>
>>82023830
You say that but then you have companies you'd think be all over encouraging strong passwords, like PayPal, enforcing a 20 character max
>>
>>82026161
theres plenty of small brained C code
>>
>>82026161
>this is why C is for big brained people only
because you have to write a ton of unsafe code to do the simplest of tasks? I would rather spend my time writing code that does useful things than masturbate over the fact I understand pointers
>>
>>82026161
c is so disgusting
>>
>>82026231
its a masterpiece of its time
obviously on hindsight C has lots of flaws
but you gotta do what you gotta do man
do you even understand how beautiful that shit is? tokenization without any allocation
this shit lit bro
>>
>>82026161
>Remove the first space-delimited token from a string and return a pointer to it
so... is this just a wonky version of strtok?
>>
>>82026174
Yes. Even in languages with garbage collection and no access whatsoever to memory you can create a memory leak (although it's often called a "space leak").

I guess it's still technically possible to have a Turing-complete language without memory leaks. A standard Brainfuck program, for example, is guaranteed to never use more than 30 KB of memory. Even then, you could argue that a real program still has physical limitations on memory usage, and because Brainfuck is Turing-complete you can implement dynamic memory allocation if you're insane enough - thus you can still have a memory leak in Brainfuck.
>>
>>82026253
>tokenization without any allocation
are you like a fresh out or something? it's not that impressive, it's literally walking through an input array to return a pointer within the array's bounds, why the fuck would you have to do an allocation for that?
>>
>>82026312
>using 2 stack variables instead of just 1, the pointer
its different and unique than just returning (left,right) indices
>>82026261
idk what the fuck is strtok
https://man7.org/linux/man-pages/man3/strtok.3.html
but it seems to have a global state? what in the actual fuck?
>>
>>82026266
>I guess it's still technically possible to have a Turing-complete language without memory leaks.
are you retarded? any well written application should never leak memory. there are many common coding practices and idioms to help ensure this, and static and dynamic analyzers to help catch non-obvious cases. if your code regularly has issues with memory leaks you're doing something terribly wrong, everything should be accounted for and freed when no longer needed. if you can't manage that you have no business writing software
>>
>>82026270
having a pointer be null is typically not an error worth of exception, especially in C (which has no exceptions anyway). it means someone explicitly set a pointer to 0 as an indication that it points to nothing
>>
>>82026338
>its different and unique than just returning (left,right) indices
no it's not, it's a design choice. return an offset to a base pointer, or return the base pointer + offset, there's almost no difference
>>
>>82026338
>global state
welcome to C, how the fuck do you think errno works?
>>
anyone have a code snippet that will let me generate an integer ID for a type passed into a template function at compile-time?
>>
>>82026340
I'm not saying it's impossible to write software without memory leaks, dumbass. What I'm saying is that it's quite impossible for an algorithm to analyze a program in a Turing-complete language and say "yep, it won't leak memory". Which is not the case for safety.
>>
>>82026370
yes there is, the interesting part of this alg is writing \0 to replace the whitespaces
instead of storing the begin and end, you just need to store the begin and infer end from strlen
its a design choice for sure, but its the first time i've seen something like this
>inb4 this is common
okay so shut the fuck up not everyone spend their days reading C code
>>
>>82026400
Do you need to access the actual value of the ID at compile time, or just have it generated? If you only need the latter, just do something like this:
#include <cstdio>
#include <cstdint>

template<typename T>
struct type_id {
constexpr static const uint8_t s_dummy = 0;
static uint64_t get() {
return reinterpret_cast<uint64_t>(&s_dummy);
}
};

int main() {
printf("ID of int is %lu\n", type_id<int>::get());
printf("ID of long is %lu\n", type_id<long>::get());
printf("ID of unsigned is %lu\n", type_id<unsigned>::get());
printf("ID of char is %lu\n", type_id<char>::get());
return 0;
}


ID of int is 4202500
ID of long is 4202501
ID of unsigned is 4202502
ID of char is 4202503
>>
>>82026253
>what is std::string_view
>>
>>82026400
pretty sure typeid has a way to let you retrieve a hash of type size_t, but I think that's only at run time

https://en.cppreference.com/w/cpp/types/type_info/hash_code

In a related vein, I've been trying some macro stuff with decltype, but haven't had success.

I'm the anon trying to make a proper serializable function lookup table, and while I got the basics working right away, I am struggling with making it type safe.
>>
im working on learning web dev because I hate my current field and want a job quickly. i already know python and am very baby tier at c++ but am improving. do you think long term javascript + c++ is a good combo overall career wise?

at the very least it lets me do cool stuff in my spare time with c++
>>
>>82026558
>C++ for webdev
not for entry level, learn C#/Java + JS instead imo
>>
>>82026476
>one byte per usage
is it possible to use a consteval int and increment it or something
>>
>>82025627
databases store stuff as a B-tree IIRC.
indexes increase speed on certain columns in exchange for more space.

you're not dumb, databases are complicated and most literature oversimplifies and skips over what its actually doing.
>>
>>82026581
ya i've been thinking java is the answer. i was looking at https://github.com/alibaba github for example and it's javascript and java. js to java is probably an easier route for me
>>
>>82026583
As of C++14 there's a "bug" in the standard with the way friend template functions are instantiated that allows some compilers which implement the behavior down to the letter to do stateful meta programming, e.g. they can have a constexpr int and increment it at compile time. Using that technique you can evaluate IDs for types at compile time and do all sorts of other weird shit. But it's an arcane technique that you probably shouldn't use outside of just showing off, and iirc it has since been declared undefined behavior in later versions of the standard. AFAIK that's the only way to *evaluate* an ID for a type at compile time, I don't think there will be any way to do it without "cheating" as it involves having state at compile time. Unless I'm missing something obvious... as for later versions of sepples, I'm not 100% familiar with them but I do not think there is any kind of stateful compile time programming in the standard yet.

Here's a link about the friend thing if you want to know more: https://b.atch.se/posts/non-constant-constant-expressions/
>>
What language has the most versatile data structures?
>>
>>82026698
lisp
>>
File: weapon_of_c++.png (70 KB, 440x955)
70 KB
70 KB PNG
>>82022393
I've already done this one. Pretty messy.
>>
File: rolled.webm (306 KB, 1020x1003)
306 KB
306 KB WEBM
>>82022319
I am working on a monopoly rip off, but it is hard game.
>>
>>82022395
No, but you need to understand that they way programming is taught in almost all schools sucks shit.
It's assumed that you've already taught yourself a lot, that you're willing to teach yourself more, and that the professor exists only to give you topics to learn and assess whether you're learning them.

You may have noticed I at no point said "is there to teach you", that's not their job. SOME of them do teach you, but their job and the job of the course is actually to weed people out.
It's very much like the process for going to a music or art school except those schools are up front about it, they expect you to already have a solid portfolio.

Much like army boot camp, the more you can do before you ever enroll, the easier and better time you'll have and more likely you'll be to succeed.
Also, while the name of the school printed on the degree may matter to the HR department, the source of the information is irrelevant. You can take community college courses, free online stuff, books, private tutors, whatever you want and then go in and ace the classes at where ever you decide to go.
>>
>>82026161
>90% of the code is pointers
>big brain
>>
File: gaam.webm (412 KB, 926x519)
412 KB
412 KB WEBM
>>82026769
Also I'm working on a Buck Break simulator
>>
>>82026796
kek
>>
>>82026698
lua
>>
>>82026782
Everything is a pointer.
>>
>>82026476

thanks for replying, i will give this a try and see if it works for my purposes
>>
File: weaponofd.png (517 KB, 1079x2340)
517 KB
517 KB PNG
>>82026713
>12 references to 'runs'
really shows how artificial this problem is.
>>
>>82026161
Using C is like being a janitor and using a toothbrush to clean up spills instead of a mop.

This code is literally unmaintainable.
>>
>>82027017
>im too stupid to understand X
>X must be wrong!!!
literal brainlet
>>
>>82026998
Yeah. I think the main thing that makes it convoluted is the need to distribute the available deletions optimally. The cases where the password is <= 20 characters are not that tricky in comparison.
>>
>>82027017
#include <ctype.h>
#include <stdio.h>
#include <string.h>

static char *GetFirstElement(char *s, char **rest) {
while (isspace(*s++));
char *res = &s[-1];
while (!isspace(*s++));
s[-1] = '\0';
*rest = s;
return res;
}

int main() {
char *s = strdup(" that's just bad code");
char *first, *rest;
first = GetFirstElement(s, &rest);
printf("%s\n%s\n", first, rest);
}

or in D:
private const(char)[] strtok(const(char)[] s, ref const(char)[] rest) {
import std.ascii : isWhite;

while (s[0].isWhite) s = s[1..$];
const(char)[] ret = s;
while (!s[0].isWhite) s = s[1..$];
ret.length = s.ptr - ret.ptr;
rest = s[1..$];
return ret;
}
>>
>>82022319
Over the year I sneaked in code so our entire system would break if there ever will be added a new gender apart from male/female. Fuck trannies.
>>
File: 1621807569628.png (36 KB, 402x402)
36 KB
36 KB PNG
>>82022319
functional programming is nazbol gang
>>
>>82022395
not at all. that said, if you didn't do any math at school then it will be pretty difficult. if you didn't I would suggest brushing up on basic math while learning programming.
>>
>>82024293
comments, multiline strings and references can be useful.
>>
>>82022395
I started programming at 27 with C. I got my first job at 33 and I kid you not I'm better than most of my peers that all started with Java or Python.

Start with C, Assembler and work your way up to C and Rust and you'll be fine. I found that the quality of programmer usually has to do with how programming was first taught. If you look at it like a branch of mathematics and learn it from the low-level up you're significantly better than people that write Java or Python code without even really understanding what is happening on the low level.
>>
File: 2Q==.jpg (4 KB, 190x265)
4 KB
4 KB JPG
Please keep your insane and technically incorrect anti-vax comments to yourself.

You don't know what you are talking about, you don't know what mRNA
is, and you're spreading idiotic lies. Maybe you do so unwittingly,
because of bad education. Maybe you do so because you've talked to
"experts" or watched youtube videos by charlatans that don't know what
they are talking about.

But dammit, regardless of where you have gotten your mis-information
from, any Linux kernel discussion list isn't going to have your
idiotic drivel pass uncontested from me.

Vaccines have saved the lives of literally tens of millions of people.

Just for your edification in case you are actually willing to be
educated: mRNA doesn't change your genetic sequence in any way. It is
the exact same intermediate - and temporary - kind of material that
your cells generate internally all the time as part of your normal
cell processes, and all that the mRNA vaccines do is to add a dose
their own specialized sequence that then makes your normal cell
machinery generate that spike protein so that your body learns how to
recognize it.

The half-life of mRNA is a few hours. Any injected mRNA will be all
gone from your body in a day or two. It doesn't change anything
long-term, except for that natural "your body now knows how to
recognize and fight off a new foreign protein" (which then tends to
fade over time too, but lasts a lot longer than a few days). And yes,
while your body learns to fight off that foreign material, you may
feel like shit for a while. That's normal, and it's your natural
response to your cells spending resources on learning how to deal with
the new threat.

https://lore.kernel.org/ksummit/CAHk-=wiB6FJknDC5PMfpkg4gZrbSuC3d391VyReM4Wb0+JYXXA@mail.gmail.com/
>>
>>82027792
Funny how Torvals makes the assumption that just because he went to university for fucking programming that he knows mRNA.
>>
>>82027792
Based. Anti-vax smoothbrain retards killed the movement.
>>
>>82027801
To be fair mRNA is the field that comes closest to programming out of all other fields besides functional mathematics.

It's literally encoding genes to make your cells produce certain proteins. mRNA = Source Code, protein synthesis = compiling, Protein = Object Code. Protein interaction with virus = Runtime.
>>
>>82027718
>I found that the quality of programmer usually has to do with how programming was first taught
Most of the best programmers of today learnt how to program with BASIC, I don't think you're correct
>>
>>82022575
Scrapers can break if elements on the target site change, an API is going to be more stable.
>>
>>82027475
FP is communism
>>
>>82027971
You can introduce a meaningful notion of state with pure functions. You just suck at math.
>>
File: OOA.jpg (250 KB, 1920x1080)
250 KB
250 KB JPG
I can't escape OO even when I'm not programming.
>>
>>82027792
>tens of millions of people have been saved
>planet has 7+ billion people
1e7/7e9 == 1.4%
kernel hacking expertise is unrelated to "make up an impressive sounding number that's actually impressive" ability
>a bunch of true statements about mRNA
whatever prompted this tirade must've been some exceptional shit arguments. Which means the tirade is wasted: someone with non-shit arguments won't be moved.
kernel hacking expertise is unrelated to putting proportional effort into your posts, huh.
>And yes, while your body learns to fight off that foreign material, you may feel like shit for a while. That's normal, and it's your natural response to your cells spending resources on learning how to deal with the new threat.
This is where he just starts making shit up. Hasn't he had a vaccine or two in his life, before this one? I've had smallpox and anthrax vaccines and didn't have this "normal" experience of feeling like shit due to my cells "spending resources". People get vaccines all the time but somehow a year of propaganda can purge these memories.
the Covid vaccines suck because the spike protein itself sucks, and that's released into your body when T cells destroy the mRNA-programmed cells. If you aren't in a high risk population for covid, don't poison yourself. In a couple of years they'll have improved vaccines that take into the account this belated realization about spike proteins.
>>
>>82028005
0.14%
see you in three days.
>>
>>82028005
Vaccines for all diseases regularly make people feel sick
>>
File: 1391418684709.jpg (6 KB, 258x195)
6 KB
6 KB JPG
>>82027792
Based Linus.
>>
>i will rather take the 1% chance of dying than the 0.00001% of dying
this is your mind of antivax
especially bad if you live with old people
>>
>>82028020
most vaccines are the disease itself, and you can get a light version of the illness the disease causes. Smallpox vaccine leaves you with a permanent scar.
the mRNA vaccines don''t actually put corona viruses in your body, so there's obviously a different mechanism at work, and it obviously bothers people a lot more (probably because it was designed against people who barely even have functioning immune systems, so need a heavy dose to provoke a response at all.)
>>
>>82028049
you're in the wrong place lad, this is a programming general.
>>
>>82024327
>>82024754
>>82027716
Appreciate the response. For my case it seems as though XML won't be necessary.
I looked into TOML, and even INI-like things but decided against them.
Going to look into and compare YAML some more to JSON, it seems like it might make more sense for configuration specifically compared to JSON.

However...
>>82025651
This is interesting. I also considered using a binary file, since people should not be messing with it directly. Rather, I should expose an API that allows for manipulating the config.
I'm working with a higher level language than C as well, so I gain the ability to take a native struct and map it to any of these formats with basically no effort.
So I could parse any format as input, convert it to a native struct, then output it in any format too.

I've heard of people doing this with XML during Sun's era. It seemed common for programmers to use XML as a template / intermediate representation, with the expectation being you can use it to validate input against I guess a schema, and then output it using a similar method.

That way anyone can just use whatever they like the most, through whatever means. Native binary for defaults, maybe a json string as input, maybe yaml as output or even connection to other programs that render it as a settings GUI. It's all decoupled.

>implying anyone is even going to use my software in the first place
>>
>>82028054
>and it obviously bothers people a lot more
why though?
>>
>>82027792
Linus confirmed globohomo
>>
>>82028056
No he's talking about Rust haters who always ask "what's the point of Rust if you're using unsafe blocks?"
>>
>>82028094
nah, that's actual text. Going to take more work to make it about Rust.
>>
So Rust macros allow you to have random keywords in the 'params', right?
Sounds to me like you could have "double variadics" like
($($first:expr),* keyword $($second:expr),*

but nothing like that is possible, is it?
>>
>>82027860
its gell Mann amnesia.
>>
>uni teacher asks me to collaborate more in work
>give teammates some random shit to do
>somehow find the worst looking, most unperformant garbage code possible
>zero willingness to learn, teached them the basics of indentation a dozen times and they dont bother even with that
>dozens of flags, badly named (a, b, c), repeated code, glued together stack overflow shit
>when I ask them why theyre doing x or what they're trying to accomplish with y they just say oh Im using some for loops here and ifs there as if that somehow helps
how do I deal with this shit?
>>
>>82028260
1. ignore the request and take a hit to your grade
2. imagine that these people are all also better-paid, more experienced coworkers, so that you won't be so unpleasantly surprised by employment
3. accept their shit code, don't touch it, put it right next to your code, and let it sit as obviously out of step, and clearly git-blamed
>>
File: 41aZ8nG0tcL._AC_.jpg (26 KB, 498x487)
26 KB
26 KB JPG
>year long lockdowns
>use the pc all day
>this week pinky and behind the knuckle dull pain
>too much mouse
I want to get something, I have the jelly pad that sits underneath but it's not always good.
Will a wrap help or is it broscience?
>>
>>82028395
buy a vertical mouse
>>
>>82026045
leak enough memory and the operating system will fail. doesnt sound very safe to me
>>
>>82028412
Are they fast? for general use, Photoshop, occasional FPS game?
It's a good idea. I imagine the higher end (logitec) will be better and actually researched for ergonomics.
>>
>>82028395
a wrap will hurt. Get this book: https://amazon.com/gp/product/1572240393/
summary: your body contains fascia. Fascia is amazing, adaptive, protective, supportive, reactive, space-age technology. Very repetitive minor injuries can also get fascia into a state it can't get itself out of. Extremely light stretching corrects it. Most of the book is "does this hurt? do this exercise". The very beginning of the book explains how the exercises help.
change your mouse. ELCOM make ball mice (and
a keyboard) where your thumb does the scrolling. Kensington makes ball mice with a giant scroll wheel that you can rotate in different ways, whatever's best. Lenovo makes USB/BT keyboards with a trackpoint for normal computers.
>>
>>82028455
vertical mice are barely different at all, they just change how your hands are angled. Kinesis makes a very light one with a single button that switches it from left-to-right handed. What I did for about a year was use my off-hand for "general use, Photoshop", and then use my primary hand for games. Often with different mice.
>>
>>82028455
the cheap one i randomly got out of curiosity has been fine
https://www.amazon.com/Perixx-Perimice-513-Vertical-Ergonomic-Optical/dp/B00GZIA2AE/ref=sr_1_1?dchild=1&keywords=Perixx+Perimice-513+Wired+Vertical+USB+Mouse%2C+6+Buttons+with+1000%2F1600+DPI%2C+Right+Handed+Design%2C+black&qid=1623409735&s=electronics&sr=1-1
Takes a bit getting used to if you want to (casually) game or do extended things with them, but very doable.
I imagine higher-end ones are probably a bit less awkward too.
If you have the money and desk space/setup, I also rec getting an adjustable desk. Standing forces you to be a bit less lazy.
>>
I highly recommend you guys get a OP that includes a pastebin with helpful links such as basic resources for C, C++, Rust, Javascript, Python. Maybe some youtube videos and other resources.

This thread has been mostly void of actual discussion and it would probably help newcomers a lot to just have access to basic information.

I offer these pieces

>Comparing compiler optimization quickly in browser to see with which compiler you should compile for the most optimal object code
https://godbolt.org/

>Best resource to learn computer graphics, the actual theory and implementation of computer graphics. So that you know how to make something like Vulcan or OpenGL yourself. Even if you never work with it it helps you understand the technicalities behind graphics and rendering better
https://gabrielgambetta.com/computer-graphics-from-scratch/

>Computer science topics for people that aren't challenged by their university program or wants to outcompete their peers
https://github.com/ossu/computer-science
>>
>>82028497
>>82028488
I am in the UK and there are these $15 ones and then there are the $90 ones like Logi MX.
I am wondering if Logi has actually spend r&d on these to actually be optimal whereas the cheap ones are just less effective. Not to mention durability.
I have a Logi G403 here since 2016. Still going strong, no issues. (except the 10 hour daily use because of the ronna).
>>
>>82028516
nah fuck off
>>
>>82028516
lmao
>>
>>82028516
>>>/sqt/ has all that already.
>>
Based commie haskeller
>>
>>82028062
autoimmune reaction to the foreign substance, that causes, among other things, blood clots.

and if you think that sounds bad, just wait until the fact that the injection can cause demyelination becomes common knowledge.
>>
>>82028497
>>82028488
>>82028456
I found a decent one in the UK. The Logi is huge for me.
https://www.amazon.co.uk/Trust-Gaming-Vertical-Ergonomic-Buttons/dp/B07JLMK5T3/ref=sr_1_15?dchild=1&keywords=vertical%2Bmouse&qid=1623410393&sr=8-15&th=1
>>
>>82022393
What is regex.
Do your own homework.
>>
Did you know that the whole universe is programmed in Scheme, including you?
Scheme is God's true language.
>>
>>82028455
It's the same as if you held the mouse with palm grip, except a lot more comfortable
>>
Guile is so cute!
>>
>>82022319
What meme language should I use for the front end? Elixir? Haskell web-dev?
>>
>>82022395
Yes.
>>
>>82028844
if you only need front-end, Elm.
If you want full-stack, give elixir + phoenix a try (and liveview)
hasklel is more geared towards back or fullstack
>>
>>82028862
I don't need a lang for full-stack/back-end, already done it. Just writing a small front end client for testing/showcase purpose.

> Elm
I have no idea what this language is, but guess I'm doing it in Elm now.
>>
>>82028892
>I have no idea what this language is, but guess I'm doing it in Elm now.
basically a subset of haskell with really good error messages.
it's bretty gud.
Or if you want a turbo-meme lang.
give Ur a look http://www.impredicative.com/ur/
>>
>>82028919
Oh man this Ur thing looks like an absolute blast, thanks anon.
>>
>>82028919
>http in 2021
>>
>>82028998
>he says over http
>>
>>82028998
>trusting the certificate jew
>>
>not using QUIC
lmao i knew all along UDP is and was superior
>>
>>82029033
>>82029027
>>82028998
>>82029093

bitcoin solves this
>>
I'm refactoring a small general purpose game/application framework I wrote a long time ago. This framework has a base type which consists of a 2D rectangular bounding box, virtual functions for handling input events, ticking, and rendering, and an array of child objects. There is one root object which contains all the others in a tree-like fashion.

In the previous iteration of this library, this base type was called Component. I like that name, but the current vogue is to have Component refer to composable parts of a whole as in the popular Entity Component System pattern, and that's not really what these are. I'm thinking I may end up adding an ECS like system too down the line, so I'm wondering if maybe I should change the name of this thing from Component to something else, but I can't think of a better name. The main purpose of these things is UI, so I was thinking of UIElement or Widget or something like that, but they're a bit more abstract than that as they can also be scenes, levels, or views of game objects. "Element" by itself sounds kind of derpy. "Object" is too general. Is there a good name for this type of class?
>>
>>82029155
Base
Root
SuperClass
>>
>>82029155
Node
>>
Anyone use scrapebox?
>>
>>82029210
>>82029212
Hmm those names are kind of general... You know what I'm rather fond of the name Component and I'd rather not retype all the places where I've abbreviated it as "cmp" and so forth. Maybe I can just use a non-orthodox name for composable parts of an ECS system if I add something like that someday. Feature or Trait seems like a good word to use in place of Component there.
>>
>>82029294
I wouldnt do that if I were you. You will regret needless ambiguity down the road. Honestly since all the objects have collision, ticking, rendering, and can handle input, they might as well be entities. UI and views should be separated explicitly.
>>
>>82022319
I'm struggling with my javascript class. I'm not a programming major but this is the last programming class I'll have to take before graduation. Javascript confuses the fuck out of me, are there any resources to learn it? It is a basic class, need help with arrays and functions etc.
>>
>>82029591
>javascript
grow up
>>
>>82029591
Well, what part are you struggling with?
>>
File: file.png (80 KB, 792x321)
80 KB
80 KB PNG
>>82029600

here is basically an example of what I'm talking about
>>
>>82022319
>>82024333
>no race conditions
pretty sure they have quite a few conditions concerning race...
>>
>>82029591
Read Eloquent Javascript, it'll only take you a few hours. https://eloquentjavascript.net/
>>
>>82027971
fp has state
>>
>>82029665
Like this?
const theIndustry = "Slave Trade";
const theProducts = [
{
type: "buck",
name: "Tyrone",
iq: 83,
timesBroken: 14
},
{
type: "sheboon",
name: "Sheniqua",
iq: 79,
timesBroken: 88
},
{
type: "buck",
name: "Jamal",
iq: 87,
timesBroken: 10
},
{
type: "sheboon",
name: "Latifa",
iq: 81,
timesBroken: 72
},
{
type: "gorilla",
name: "Koko",
iq: 90,
timesBroken: 0
},
{
type: "buck",
name: "Deshante",
iq: 80,
timesBroken: 20
},
{
type: "buck",
name: "Kunta Kinte",
iq: 88,
timesBroken: 31
},
{
type: "sheboon",
name: "Latanya",
iq: 76,
timesBroken: 40
},
{
type: "buck",
name: "Tariq Nasneed",
iq: 82,
timesBroken: 95
},
{
type: "buck",
name: "Michelle Obama",
iq: 81,
timesBroken: 59
}
];
>>
>>82029696
Maybe they should use less threads then?
>>
>>82030002
yes like that. thanks anon.

the issue I have with JS is the syntax for the most part. I always feel like I understand when to use a function or method but never know how to implement it properly
>>
>>82022393
> create a password generating iterator
> apply isValid each time
> apply minimum edit distance algorithm
Go get your homework done elsewhere.
>>
>>82030148
relax retard it's a daily programming thread.
>>
>>82030222
Right, it's daily programming thread, not daily copypasting thread.
>>
>>82030234
dilate
>>
I have a question about Floating Point representation.

Assume the following 24-bit floating point format with value = (-1)^s x 1.F x 2^(E-255)
E=000000000 to represent zero
and E=111111111 to represent infinity.

S is one bit
Exponent is 9 bits and the fraction is 14

what are the limits of what I can represent here? what are the maximum and minimum positive and negative numbers?
>>
>>82030278
I don't follow your daily schedule, because I'm not a mentally retarded tranny unlike you.
Time for your meds, anon.
>>
>>82030278
calm down man. get off 4chan for a bit and start speaking like a regular person instead of the shit you're spewing
>>
>>82022393
took me longer than I'd care to admit but i think i got it
https://termbin.com/4ul5v
>>
File: pw.png (1.43 MB, 1910x1047)
1.43 MB
1.43 MB PNG
>>82030535
forgot pic
>>
how does C++ handle C bools in a library? Are they treated as integers or booleans (can I use them in equations)?
>>
Day one of learning C. I'm making a simple journal program that has makes a markdown file with current date as the name and the current time appended to the file every time the program is run.

How do I go about making fprintf print the output of strftime? I'm still thinking in terms of shell scripting. This is how far I've got.

#include<stdio.h>
#include<time.h>
#include<sys/types.h>
#include<fcntl.h>

int main() {
char s[30];
int fp;
size_t i;
struct tm tim;
time_t now;

now = time(NULL);
tim = *(localtime(&now));
i = strftime(s,30,"%Y-%m-%d-%A.md\0",&tim);

FILE *f;
f = fopen(s, "a+"); // a+ (create + append)
if (f == NULL) { /* Something is wrong */}
fprintf(f, "Here is where I'd like to put a timestamp.\n");
}
>>
File: array.jpg (32 KB, 549x604)
32 KB
32 KB JPG
I'm an amateur at this shit and just want to ask if this is a dumb way to make an array that keeps track of all the properties of an object. It seems to work but I doubt I picked the best way.
>>
>>82026698
haskell
>>
>>82026698
Probably some static + strong fp lang.
>>
>>82031003
The only dumb thing there is how you named the fucking struct members. Fix them right now or I'll virtually cave your head in with a virtual crowbar.
>>
>>82030002
Shit forced meme.
>>
>>82031003
You would probably want to use enums for the Suits and Values but since you are using C lmao
>>
>>82030668
C doesn't have bools.
>>
>>82031138
C has had bools for over 20 years now
>>
>>82031138
_Bool
>>82031154
It did?
>>
>>82031003
It's fine. Don't use random letters like i j k for the variable names though, use proper names. And you should probably make value and suit integers/enums instead of strings.
>>
>>82031175
>>82031109
>>82031039
Thanks
>>
>>82031162
>>82031154
Oh, shit I forgot that existed.
>>
fml need a new project. i miss being in the autistic flow for whole days.
>>
>>82030898
int a = 1;
int b = 2;
printf("%d + %d = %d, %s\n", a, b, a + b, "nigger");

https://linux.die.net/man/3/printf
>>
How do I get better at programming under exam pressure? I'm not bad at programing, I've written some nifty stuff like parallel sorting, convex hulls etc, but whenever I get put on a exam I just turn retarded. I couldn't even write a doubly linked priority queue today. Is grinding leet code the only solution?
>>
>>82031322
Memorizing algos is just memorizing. If you have bad memory you aren't going to make it without heavy repetition effort long before the exam, I know this because I have a complete fucking shit tier memeory.
>>
>>82031258
A Steam clone for pirated games, supporting save backup, plus an overlay that hooks into the games to provide achievement earned notifications on exclusive full screen games.
>>
>>82031322
Practice under the same conditions as exams. Apart from that work on handling stress/anxiety.
>>
I'm trying to navigate javascript roadblocks when trying to send a post request.
First I tried requests_html, then selenium's 'post' option, but neither are a successful enough solution.
Any other ideas?
>>
>>82031003
Using struct with 3 strings is inefficient as fuck. Make a struct with 3 uint8_t, or just regular ints, for IDs and a lookup array of strings.
>>
File: 1612498670875.png (353 KB, 695x640)
353 KB
353 KB PNG
>>82022575
>will only be parsing about 50 items each day. how do I know if using external parsers 50 times will trigger bot detection?
>50
It won't kek. I've used selenium to scrape so many sites and never got locked out once
>>
C++ is a meme
There is literally no jobs available in my city/state that requires that languaje, they only want javascript/php developers.
it looks like i need to take the webshit pill or starve
I fucking hate my life.
>>
>>82031322
Program as much as you can before the exam starts, Preferably within 48 hours of the exam starting. If you know the type of programming problems you're going to encounter then try programming them. Use your smartphone as a timer and try to speed up.

You have different type of programmers. There are 3 broad types of programmers.

>Sprint and improvise
These type of programmers just write as quickly as possible whatever comes up in their mind, compiles it and if it doesn't work like expected they just slowly change the code until it works.
>Memorization based
These are the type of programmers that specifically learn the solutions to specific problems and always applies the same solution to the same problem. If they don't know the solution they usually become stuck
>Think then execute
This is my personal style. Here you completely think out a solution sometimes with pen & paper and only start writing the code when you already have the complete planning in your mind.

So depending on what type of programmer you are you should tackle the exams. If you're a sprinter you need to practice writing code faster. If you're a memorizer you need to train the specific problems and solutions. If you're a thinker you need to get the process of putting it on paper faster so that you can start typing the code.
>>
>>82031956
That's why I got rich on crypto first. I just do this for fun.
>>
>reading the iterators/collections chapter of programming rust
why is rust so perfect
>>
>>82031956
C/C++ requires embedded to thrive. Also the vast majority of software engineers/programmers move cities to get employed. Almost no one I know actually stays in their city for work.
>>
>>82031987
fuck off
>>
>>82032002
Because they were wise enough to copy ML (should have copied its module language too, idk what the fuck went wrong there)
>>
>>82032004
this is what I did.
>>
>>82031154
stdbool is just #define True 1 #define False 0, it's not a real bool
>>
>>82032002
It's not. There's so many things that could be cleaned up if they had monads, HKT, etc.

Also look at how traits are defined for tuples. It's disgusting.
>>
>>82032138
Monads are not needed, they just confuse people.
I would like GADTs though, I've used them in Ocaml and they're delightful.
>>
>>82032163
Just don't call them Monads and people would be fine.
>>
File: 1614494321676.jpg (26 KB, 251x242)
26 KB
26 KB JPG
>>82022319
On your mother!
>>
is there such a thing as linked merges for gitlab / github? like if you make a change to 1 repository but it's dependant on changes to another, can you sync those merges, or compile them all into a single merge request that affects 2 repos?
>>
>>82022393
in shell this is just
#!/bin/sh
s() {
sed -E -e 's/((.)\2\2+)/\n@\1\n/g' | sed -n -E 's/^@(.*)/\1/gp' | {
while read -r l; do v=$((v + ($(printf '%s' "$l" | wc -c) - 1) / 2)); done
[ ${v:=0} -lt 0 ] && v=0
echo "$v"
}
}

c() {
v=$((3 - $(sed -n -E -e 's/[[:upper:]]//p' -e 's/[[:lower:]]//p' -e 's/[[:digit:]]//p' | wc -l)))
[ ${v:=0} -lt 0 ] && v=0
echo "$v"
}

max() { printf '%s\n' "$@" | sort -r | head -n1; }

steps() {
x=$1
len=$(printf '%s' "$x" | wc -c)
reps=$(echo "$x" | s)
uniq=$(echo "$x" | c)
if [ "$len" -lt 6 ]; then
add=$((6 - len))
echo $(($(max "$add" "$uniq" "$reps")))
elif [ "$len" -gt 20 ]; then
del=$((len - 20))
echo $((uniq + $(max "$del" "$reps")))
else
max "$reps" "$uniq"
fi
}

steps a
steps aA1
steps 1337C0d3
>>
File: 1623374019315.png (180 KB, 519x533)
180 KB
180 KB PNG
>>82032163
>monads filter me
That's the point
>>
>>82023365
>"aaa123" - should be 2, got 1
making aAaa123 is 1
>>
>>82023243
Small thing: you don't have to branch in the first part of the for loop:
    bool lCase = false,
uCase = false,
digit = false;
for (const auto c : password)
{
lCase = lCase || islower(c);
uCase = uCase || isupper(c);
digit = digit || isdigit(c);
if (c == curr)
{
++cnt;
}
else
{
if (cnt > 3)
repeats.push_back(cnt);
cnt = 0;
curr = c;
}
}
>>
>>82023774
yeah it's not strong, it's very strong :^)
>>
I'm at the "deconstructor" part of this C# tutorial: https://www.tutorialspoint.com/csharp/csharp_classes.htm
It's not calling the deconstructor, though. I even tried copypasting the example, I only get the first two output lines.
Any reason why it wouldn't get called?
Tried to put class usage inside brackets to force it, but no dice either.
>>
>>82032594
Not a C# fag, but try flushing the output in the destructor. I'm guessing it's going into a buffer and is never flushed on exit.
      ~Line() {   //destructor
Console.WriteLine("Object is being deleted");
Console.Out.Flush();
}
>>
Why is std::list so neglected compared to the other C++ containers? fucking bjarne stroustrup despises them and he created the language
O(1) insertion and deletion has it's place, all it needs is a standard library implementation that can be cache friendly
>>
>>82032748
>list
>cache friendly
How? If you want O(1) insertions, what would that look like?
>>
>>82032678
Tried, didn't work. Thanks anyway, Not a C# fag.
Apparently it's because the deconstructor is literally useless and gets called whenever the garbage collector takes a break from laughing at my life.
>>
>>82032748
>all it needs is
That right there, faggot. Accept that your favorite data structure is a shitty, needy whore.
>>
>>82032903
They're "destructors" not "deconstructors" but yes, in GC'd languages, destructors run when the GC runs it. You can try adding:

line = null;
System.GC.Collect();


to the end of main. Not sure why your runtime isn't running destructors on exit if that is the case.
>>
File: momhelp.jpg (178 KB, 1233x691)
178 KB
178 KB JPG
have you ever programmed a game anon?
https://www.youtube.com/watch?v=XpzBfx45wUE
Now, right now, is the time.
>>
>>82033058
games are for kids and faggots.
>>
>>82033005
>They're "destructors" not "deconstructors"
Thanks, just realized I've been calling them wrong my whole life. Whoops.

Did not work, even adding
GC.WaitForPendingFinalizers();

like I found on stackoverflow didn't help.
>>
>>82033124
How are you running your program, anyway? (eg. is it a windows prompt that closes when it finishes?)
>>
>>82024333
Capitalism requires a state to function
>>
>>82033166
Tried both from VS and from the build folder, both debug and release targets.
>>
>>82032919
Literally no better data structure for making a scheduler
>>82032866
All the standard library needs is some form of controlling memory allocation for containers; not sure what you mean though, for an O(1) insertion, all you need to do is store an iterator to the element you want to insert after.
>>
>>82033215
>Capitalism requires a state to function
You clearly don't know the influence of supply and demand and how black markets function, then.
>>
>>82032163
monad is just about composing two datatypes, that's it
>>
>>82033258
>making a scheduler
Ok... and? Other use cases?
Structures are meant to work for a wide use case.
>>
>>82033215
Not really. As long as people are willing to sell food and roofs for money, there will be capitalism.
>>
>>82032594
Works for me on https://replit.com/languages/csharp
>>
File: knive.jpg (109 KB, 692x574)
109 KB
109 KB JPG
>>82033075
are you a kid?
>>
>>82033294
C++ is not a general-purpose programming language.
>>
>>82033215
I know commies are stupid but wew
>>
>>82033258
>not sure what you mean though
I'm asking you what YOU meant, you illiterate bastard.
>>
File: 26626.png (1.16 MB, 1736x864)
1.16 MB
1.16 MB PNG
gmtk game jam theme
>>
What would look prettier/be more useful? Example: i want to write to an already existing file so

- Should I check if the file exists and do stuff?
or
- Should I just put everything on a try except?
If you were reading code, which would be easier for you to understand? btw not in this example, but in every other situation like this
>>
>>82033332
look up what an arena allocator is you fucking retard
>>
File: iimanattackhelicoper.jpg (13 KB, 461x306)
13 KB
13 KB JPG
>>33332
I'm asking you what YOU meant, you illiterate bastard.
>so9 close
>>
>>82033328
>C++ is not a general-purpose programming language.
https://en.wikipedia.org/wiki/General-purpose_programming_language
Look at the very first language listed.
Then neck yourself already, because you're clearly too dumb to exist.
>>
File: seethings.png (693 KB, 1281x789)
693 KB
693 KB PNG
>>82033333
faggot aids programmer C$$
>>
>>82033353
I know what that is, but apparently you don't. That's not really cache friendly. It's more allocate friendly. It's not going to ensure that members of the list are next to each other in memory.
>then just allocate them in slots right next to each other
Great, until you start adding to the list and it degenerates. Either that or you need start moving things around, which isn't O(1) anymore. You can sort get an amortized version with a slab allocator though.
>>
is getting autistic about minimizing heap bad?
>>
>>82033805
my boss thinks so
>>
>>82030898
You call to fopen is a bit odd as it uses s, your string containing the timestamp as the filename. Is that what you intended? Are you trying to put the same timestamp as the file name into the file? If so, it'd look like:
    fprintf(f, "%s\n", s);


Having the filename and the file contents seems a bit odd, though.

int fp is unused.
buffer s is sized for 30, and the way your call to strftime will ensure that it is null terminated, but be aware that giving a size of 30, the max number of bytes to write doesn't include a null. Putting it in the format string isn't a bad idea, but if it the output was actually 30 characters, it would write all 30, then a null, overrunning your buffer by 1.
>>
>>82033805
i think so

>>82033834
back to work
>>
>>82033839
Based code-review anon
>>
>2021
>no heapoverflow
>>
File: 443.png (1.42 MB, 1746x925)
1.42 MB
1.42 MB PNG
>>82022319
Released my second browser game:
https://fortune-for-the-princes.herokuapp.com/
>>
>tfw you learn about Descriptors in Python
Now everything makes sense

https://docs.python.org/3/howto/descriptor.html
>>
>>82032138
the problem with monads & hkts is that lifetimes exist
>>
A twitter bot that detects propaganda
yes Im a faggot
>>
>>82034377
Retard.
>>
Can someone explain what the difference is between qt, qml, kde frameworks and kriigami? As far as I understood qml is just a embedded version of qt with nicer animation with a js like language. KDE frameworks is just a extension of qt but wtf is kirigami? A spin off of qml/qtquick?
>>
>>82034377
def is_propaganda(post) -> bool:
return True
>>
File: 1609692136271.jpg (1 KB, 40x40)
1 KB
1 KB JPG
do these to memory allocations
----- 1
color.pixels = (int*) malloc(image->width*image->height)
----- 2
color.pixels = malloc(image->width*image->height)

alocate the same amount of bytes?
if i want allocate for an int variable must i times it with 4?
>>
>>82034766
Yep, malloc parameters are the same, you're just casting the result. You could cast it to YourDumbStruct* for all it cares.
And yeah, width*height gives you total pixels, if each pixel takes 4 bytes to store then you need to account for that.
>>
>>82034766
yes and yes
>>
>>82034766
>>
>>82034814
For clarity and for the sake of the next poor soul that has to turn their head in the general direction of your code, asshole.
>>
>>82034077
how do i join a kingdom?
>>
>>82034834
Present your asspussy to the princes, one of them might pick you up.
>>
>>82034834
ah, in courts
>>
>>82034814
>>82034833
it's also required for C++ compatibility iirc
>>
>>82034766
yes, they allocate the same amount. The value given to malloc is the count in bytes.
>if i want allocate for an int variable must i times it with 4?
The usual way, if you are expecting width*height number of ints, is to use the sizeof operator:
color.pixels = (int*) malloc(image->width*image->height * sizeof(int) );

If you need it to be specifically 4 bytes, then multiply by 4.
>>
File: 0004.png (4 KB, 64x64)
4 KB
4 KB PNG
>>82034806
>>82034808
thanks
>>82034814
must i not?
>>
>>82034149
>lifetimes
Pure headcanon
>>
Just want to thank you autistic fucks

I got a C/Unix programming job offer for 50% more than I've ever made thanks to yall with almost no real experience besides video game tinkering

Bless yall
>>
>>82034913
>>82034913
>>82034913
>>
>>82034898
It's all suffering from here anon
>>
>>82034149
Elaborate
>>
>>82023514
No. Stop being a faggot.
>>
>>82023361
Cloned :^)
>>
>>82023514
Not worth it if you cap the fps.
If he's not capping it then he deserves to be shot for creating malware that uses 100% resources for no reason.
>>
>>82034834
>>82034845
If you have other questions, they might be found from here: >>>/vst/611051
>>
>>82035030
>>82034983
People like this are why the turbo button was a thing.
>>
>>82034077
how do i see how many players there are?
>>
Forcing myself to go through a book of data structures and algorithms in C to improve my understanding. Usually there are pitfalls that shake my patience, but today I'm also sleepy and irritated, it's has been hard. I'm coding hash tables; they are alright, but I feel the author is not focusing in the worst case (too much data in the same bucket) enough and I'm having a bit of a hard time developing on my own a solution to an online judge. /blog
>>
>>82034898
Good luck, my lad. Go easy on yourself when you hit the wall and always take breaks away from problems.
>>
>>82035566
it is a single-player for the time being, you are playing against 3 AI.



Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.