/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: Wirth.jpg (300x300, 11K)

Other urls found in this thread:

youtube.com/watch?v=KZauJKmjx-Q
youtu.be/4mN_pXRbAdM
github.com/nodef0/gorillas-rs
clang.llvm.org/docs/Modules.html
en.cppreference.com/w/cpp/compiler_support
clang.llvm.org/cxx_status.html#p1103
gnu.org/software/gcc/projects/cxx-status.html
a.co/cH4pS0N
langband.sourceforge.net/faq.html
projecteuler.net/problem=67
twitter.com/AnonBabble

Are we posting our crushes?

Attached: john-mccarthy.png (542x506, 345K)

Given an integer n, return the number of trailing zeroes in n!.

Example 1:
Input: 3
Output: 0
Explanation: 3! = 6, no trailing zero.

Example 2:
Input: 5
Output: 1
Explanation: 5! = 120, one trailing zero.


p.s.: Your solution should be in logarithmic time complexity.

Given a non-empty array of integers, return the k most frequent elements.

Example 1:
Input: nums = [1,1,1,2,2,3], k = 2
Output: [1,2]

Example 2:
Input: nums = [1], k = 1
Output: [1]


p.s. You may assume k is always valid, 1 ≤ k ≤ number of unique elements.
Your algorithm's time complexity must be better than O(n log n), where n is the array's size.

A-Anone... I'm ready for you JavaScript lesson!

Attached: 13f610adf8cb560f3b0623653d0d5ef2.jpg (680x1024, 83K)

is it sorted?

n / 5
/ is integer division

doesn't matter

so it might not be sorted then

Sorry, I don't teach SLUTS.

females cant be programmers

I'm actually starting to like Javascript... what have you done to me...

a doll with moefang

Attached: 1496079688613.jpg (500x300, 23K)

25

logarithmic with respect to what?
reverse bitscans are easy, calculating factorial is either a lookup table, raw calculating it, or using some other easier formula.

programmers cant be females

const types = {
bigint: {
i: 2n,
result: 1n,
ten: 10n,
zero: 0n,
},
number: {
i: 2,
result: 1,
ten: 10,
zero: 0,
},
};

function factorial(n) {
let { result, i } = types[typeof n];
for (; i zero; n = n / ten | zero) {
if (n % ten !== zero) {
break;
}
++result;
}
return result;
}

females (male) programmers

i don't under stand, can someone explain this to me:
why is my program able to be decompiled with dnspy even though its programmed in c++, visual studio? i thought you could only do that to c# and javascript cause they use an intermediary language? why does virtually every other c++ thing unrecompilable? what options do i need to stop this

probably because it has some form of debug info in it. better question: why do you even care?

there's nothing can't be decompiled.
you can try to obfuscate your code to make it harder to read.

build histogram in O(n)
sort histogram by frequency
take k
iirc there are sorting algorithms that are better than O(n log n) if the list is almost sorted (which it is if the size of the histogram is similar to n, since most of the frequencies will be 1).
If the histogram is not almost sorted, its size will be sufficiently smaller than n, so still better than O(n log n)
I'm not sure how to prove that last point though, or if it's even true.

you're not using C++/CLI are you?

youtube.com/watch?v=KZauJKmjx-Q

> i: 2n,
error

y-yes

why do people do

variable || 0

i dunno maybe
i chose clr empty project in visual studio

Dabbling a little bit into Idris (elaborating on it for a pure math context)

youtu.be/4mN_pXRbAdM

Attached: idris.jpg (748x421, 40K)

ah now i googled it and i think it makes sense

good lad, how you liking it?

pic

It's a bitwise OR to ensure decimals are truncated

Attached: unknown.png (499x705, 24K)

anyway, the reason was that i didn't want to have people laugh at my code
also it had some sort of sensitive information like emails n passwords n shiet

so I've been learning C (again), and I have a solid understanding down
What are some simple programs that don't require any complex libraries I can work on for a week or so to strengthen my skills? All I've been able to think is a text editor, but I'd rather not.

i tried
$node test.js
got
\test.js:3
i: 2n,
^

SyntaxError: Invalid or unexpected token
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)

Good lord this us easy. Wtf dpt?

The number of 2 factors in the result outpaces the number of factor of 5s, so we really only have to factor in (heh) the number of factors of 5s in the result.

The result is N/(5^1) + N/(5^2) + ... to the point where 5^X > N.

Made the destruction algorithm not completely retarded.
Source code and playable wasm version is here:
github.com/nodef0/gorillas-rs

As far as the 3 dependently typed language go, I guess I like it. I got the book of Brady actually already 2 years ago but never got far as I went into a C++ job in AR. My interest in it is mostly purely mathematical.
And generally memes. Like

let primes = [n | n

Attached: props.jpg (3001x1836, 1.03M)

The superior version! :)

>easy
next time i'll post a graph traversing problem

Update to 12, you must be using an ancient version.

>node -v
>v8.10.0
damn

That can't be correct.
100! must necessarily have two more trailing zeroes than 99! since 100! is 99! * 100, but your solution will only give it one more trailing zero.

>including emails and passwords in any source at all
wtf are you even doing you absolute brainlet

or just count the number of pairs of (5,2) from 0 to N

int fac_trailing_zeroes(int n)
{
int ans = 0;
while (n > 0) {
n /= 5;
ans += n;
}
return ans;
}

It was required by the boss. We recently had a NSA advisor/consultant giving us a talk about best practices.

how long for gcc or clang to implement the C++20 modules

ask a refund on that consultance and fire your boss then

clang now, gcc ??? clang.llvm.org/docs/Modules.html

-.-

They already support much of the upcoming standard aka C++2a:
en.cppreference.com/w/cpp/compiler_support

oh, I was looking at this
clang.llvm.org/cxx_status.html#p1103
gnu.org/software/gcc/projects/cxx-status.html

I have some free time, is SICP a dumb meme?

it's a meme, not a dumb one.

if you want to learn scheme, no.

Yes. Read any of these instead: a.co/cH4pS0N

Attached: 41QA2K0PEPL._SX325_BO1 204 203 200_.jpg (327x499, 25K)

>Stirnerite

God save us from these insufferable blowhards

SICP is in that list

It is a better ocaml thanks to having unsigned ints and an actual parallelisation support

Fell free to read it then.

That's quite a broad stroke you got there, but okay the /lit/ bros to which every word is a potential spook are indeed extremely annoying.

Attached: crew.jpg (437x651, 57K)

>mfw someone wrote a big old roguelike in fucking Common Lisp
(that is (pretty (based) ) )
langband.sourceforge.net/faq.html

Attached: 131779.jpg (480x274, 39K)

(defun (n)
(loop for x from 1 to (log n 5) sum (round (/ n (expt 5 x)))))

Great, another series of book I will never succeed to go through...
I feel like I know fucking nothing. Jesus christ I am a failure. Too much to know.

Attached: 1562446023199.jpg (620x640, 33K)

bumping my q

Text editor is not a simple program

>better ocaml
*looks at modules*

Attached: 1545347376531.png (451x619, 429K)

>some pajeet keeps emailing me asking for his 99 cents refund from the app store
>emails me 8 fucking times
>fine
>refund it, tell him it's done
>emails me 2 minutes later saying he didn't get it
>tell him it takes 3-5 business days
>5 days later emails me saying he still doesn't have it
is 99 cents this big of a deal to people in the 3rd world. I don't even know what to do now.

Nice blog

Attached: tumblr_pgtrw4vgXO1s7wged_400.jpg (400x400, 36K)

fuggg
ive been using printf("%*s", size(), data()); all this time not realizing that it only specifies a minimum string length.

>tfw interested in compilers, language design, OS's , type theory, higher math(s) because of FP, and games
I truly am jealous of autists with one sole interest.

did you make a Release build or a Debug build?

I have the same experience with crypto airdrops. People will spend hours and fill out various forms to get to $1.25.
It's a principle thing I think. "Free money". As if dedicating 3h to it wouldn't be worth anything.

Yeah. I am way too fucking curious. I actually end up not doing much because of it. My friend laughs at me for not doing anything but the guy literally only understands C# and has such a narrow understanding of programming.

I still envy him. This is a curse. Make me stop going through learning hell.

try reading offline
leave the computer
leave your phone

how do proceed? Do I actually need to waste my fucking time contacting google asking them to look at it. I'm afraid this guy is gonna bounty hunt my loved ones for his 99 cents.

user is right. Who ever is making you hard code passwords is in sane. Unless you're lying and you just did it.

>refunding $$ from an app

did you try to scam people or something?

>professional spy recommends divulging personal info
surprise, surprise

i don't know if you guys are pretending to be stupid or are just stupid.

>is it a big deal?
yes, but that doesn't necessarily mean he didn't get it

This answer is super short in my shitlang.
f n=a0:??n+a/n5

I wonder myself

That J?

No it's a language I made.

If you know what you're doing it's a pretty comfy scripting language. You can tell with the new updates they're trying really hard to make it less shitty.

Attached: 1498564882917.png (1001x823, 806K)

I'm self studying C++ and am looking for information on graphics; I want to move past console applications. Could anyone point me in the right direction? 2D, not 3D, UI, windows, etc. I don't know what I don't know, so I can't exactly google this without landing myself into a huge rabbit hole of stuff I don't understand.

It's still too much... and my friend is making fun of me for learning "useless shit" and not "just doing simple stuff in C#". I just can't fucking do it.

An observation helpful for large numbers: trailing zeroes are preserved and accumulated across multiplications. A number with x trailing zeroes times a number with y trailing zeroes -> result has x+y trailing zeroes.

In other words: you can count zeroes *and remove them from your multiply-accumulator variable* at each step as you're calculating the factorial. It's going to be the same number of divisions and multiplications either way (so the same in Big O notation), but you'll be doing them on fewer digits, so it'll be faster overall.

this thread's project euler problem is:
( 744 - 1 ) % 677 + 1= 67

projecteuler.net/problem=67

Attached: euler.jpg (480x600, 115K)

If you just want to get 2D shit on the screen and don't care about learning how things actually work just use the SDL library, it's dead simple and there's lots of tutorials. If you actually want to learn how graphics work and not use an external library, the first thing you need to realize is that modern graphics APIs are always 3D, even if you're only interested in 2D what you'll end up doing is positioning flat planes in 3D space and rendering textures to them. You will want to write a simple vertex shader that maps your 2D coordinates to the right positions on the screen, and a pixel shader that pulls pixels from your texture image and puts them on the screen. You can do this with DirectX, OpenGL, etc.

Stop using python!

Attached: python is for jews.png (1459x586, 2.45M)

Is this going to be a valid sepples program in ten years?

Attached: D3788577-CABA-4B24-AB50-E73F10D4118F.png (600x566, 272K)

i i i i i i i ooooo o ooooooo ooooo ooooo
I I I I I I I 8 8 8 8 8 o 8 8
I \ `+' / I 8 8 8 8 8 8
\ `-+-' / 8 8 8 ooooo 8oooo
`-__|__-' 8 8 8 8 8
| 8 o 8 8 o 8 8
------+------ ooooo 8oooooo ooo8ooo ooooo 8

I'm working on a filesystem that marks files with tags instead of having folders, I've finished the database component and bare bones fuse shit and I can't be fucked to implement the remaining 20 or so fuse operations or clean up the code so I can finally throw it onto my NAS and github. I started two weeks ago and haven't written a line of code for 9 days.
How the fuck do you stay motivated past experimental prototype lads?

hello world in 2032
auto import

auto main() -> auto return
{
static constexpr reflexpr auto std::auto -> "Hello World";
}

Could you explain why the SDL library is the dead simple braindead option?

It simplifies window creation and setup and all that into just a few function calls, and it gives you simple functions that just take 2D window coords and an image and paste the image to the window. It's very easy to get started with.

For personal projects, is there any reason to use websites like github and gitlab versus just using git locally?

The only real reason I can think of is having offsite backups and that's pretty significant in itself but I was curious if they have anything extra to offer.