Quasari

joined 1 year ago
[–] [email protected] 2 points 10 months ago (2 children)

Without memoization, I believe the Fibonacci sequence is O(2^N). It's dependent on how long a sequence of digits is in the input, so your worst case is like O(2^N) if the string is mostly digits and best case being O(N) if there are only 1 or 2 digit sequences.

Someone can correct me if I'm wrong.

[–] [email protected] 2 points 10 months ago* (last edited 10 months ago)

So, I also realized its the fibonacci sequence for number of combinations of numbers. All I care about is counting sequential digits, we skip a character after every sequence. We just need to account for if the first character is a number and we are good. I did this in ruby. I didn't really try for anything bonus points wise.

Pastebin because formatting doesn't like & or <

My code also outputs 0 if the sequence itself is invalid(ends on a non-digit character, or has two non-digit characters in a row)

[–] [email protected] 0 points 10 months ago* (last edited 10 months ago) (1 children)

I found this one easier than the medium as well. Maybe because I actually know a strategy for this one. Anywho, solution is in JavaScript. It's super ugly as I went for lowest character count, so no declarations, single char variable names, no semicolons, etc...

Basically use a anchor-runner pointer strategy to find a correct substring, I use a stack based solution for checking if the substring is correct. When the stack is empty, the substring is good, thus I record the start of it and its length. If, I get another good point, I just record the highest. If I hit a point where its no longer good, I jump the start to the end of the most recent good substring. Pretty fun.

Formatting screwed mine up, so heres a pastbin

[–] [email protected] 4 points 10 months ago (1 children)

To be a superset, all elements of the subset must be contained within the superset.

TypeScript is a superset of JavaScript as valid JS code(just with everything implicitly the any type) is valid TS code.

[–] [email protected] 7 points 10 months ago

Add to it the gun law was declared unconstitutional by the fifth circuit Court of appeals recently, it's likely the only charges he'll be facing are tax related. It's funny because the gun charge was the only thing holding back his plea deal.

[–] [email protected] 17 points 10 months ago

It was 50k doubling each day. So 50k + 100k + 200k for 3 days, if they had let it keep going it would of hurt a lot. This type of fine works.

At 10 days would be 51 million, after 20 would be 52 billion dollars. So, they have a compelling reason to comply with haste.

[–] [email protected] 2 points 11 months ago (1 children)

It starts at the local level. National 3rd party candidates are just spoilers used to split the vote enough for one side to win when they wouldn't in a 1v1. Until the third party builds enough momentum in city->county->state elections they will never be viable nationwide.

Instead of focusing on the national, they need to pick a few places to focus on and grow viable candidates throughout the whole process. If they can flip one state to the third party, then we might start talking about their viability.

[–] [email protected] 4 points 11 months ago* (last edited 11 months ago)

The problem is if you play their games like they play them you legitimize everything. If you start cheating like they do, their lies about you become truth and it's all down hill from there.

The only chance the country can be saved is if the electorate wakes up. Part of the country still playing by the rules allows us to be able to go back to all of the government playing by the rules. If they give up on that, there is no coming back.

[–] [email protected] 5 points 11 months ago (1 children)

Neither was Ted Cruz, but he still ran in the primary.

[–] [email protected] 34 points 1 year ago* (last edited 1 year ago)

OSHA still requires reasonable water breaks. This law doesn't override that. If you aren't allowed one, report them.

[–] [email protected] 18 points 1 year ago* (last edited 1 year ago) (1 children)

Array.prototype.sort if no callback is passed to it will coerce non-undefined elements to strings when sorting. It does do that.

To sort numbers passing a function like (a, b) => a - b is good enough.

[–] [email protected] 1 points 1 year ago

Jesus Christ the Nazis were the National Socialist party, you don't say. It's all over Wikipedia and encyclopedia articles. Like seriously, this isn't being hidden. In fact, it's typically blasted by right-wing propaganda to say that liberals are the true nazis.

It doesn't matter because the nazi definition of national socialism is far more rooted it capitalism. The socialism partof it was more about encouraging the public to take part in public projects for the betterment of the Aryan Race. There was still private ownership, and we get our word for privatization from Nazi policies.

view more: ‹ prev next ›