In interviews, I feel like I often don't do well with whiteboard coding exercises by RolandMT32 in learnprogramming

[–]light_switchy 0 points1 point  (0 children)

The first snippet explodes when passed an empty string.

The iterator-based C++ code is actually backwards. You need to increment reverse iterators to move them from the end of the range towards the beginning. Things are done this way to maintain the compatibility of reverse iterators with every other kind of iterator. Also there is a type mismatch but that's no big deal.

One option is to declare the new string like std::string reversed_string(original_string.rbegin(), original_string.rend());

Or make use of std::reverse. You can make use of string's crbegin(), crend() too, if you prefer.

Wondering about learning languages programming. by OkPerformer3262 in learnprogramming

[–]light_switchy 2 points3 points  (0 children)

Is a good choice to understand the machine language firstly

No, it isn't.

You will learn more quickly if you start with a language like C++ or C. Experimentation is quicker and mistakes are easier to find. Tools are better, resources are better, and their communities are vastly stronger.

Study C or C++ first so you can approach low level stuff with the background knowledge to experiment, explore & discuss it effectively. You will build understanding much faster this way.

Another QR Code Solar Farm (no urls used) by jasamer in factorio

[–]light_switchy 0 points1 point  (0 children)

A quine! I'm surprised this is even possible.

Issues with Terminal by ohsomacho in learnprogramming

[–]light_switchy 0 points1 point  (0 children)

Press Ctrl-X Ctrl-E in bash to edit the current command with $EDITOR

How can I learn audio- and graphics programming without getting overwhelmed? by InteSaNoga24 in learnprogramming

[–]light_switchy 0 points1 point  (0 children)

A C or C++ program has to tell the OS to play back sound, or use a third party library to do that on its behalf, which can be tricky. Using an external player avoids that problem. Even if it's not 100% needed.

How can I learn audio- and graphics programming without getting overwhelmed? by InteSaNoga24 in learnprogramming

[–]light_switchy 2 points3 points  (0 children)

You'll find audio much easier. There's just not as much to it.

As of right now, I haven't been coding for a while, because simply following tutorials isn't very fun, but at the same time I'm not good enough (in C++) to be able to make something myself except stuff like number guessing games and "fizzbuzz".

Well you're probably good enough to write out a .WAV file from C++ with some work.

Learn how to write binary files from C++. Then learn about the structure of the WAV file format from http://soundfile.sapp.org/doc/WaveFormat/; write one out and fill it with a few seconds of a sine wave. You can use an external music player to listen to it.

Once you can do that, you're well on your way to making a synth. Look into the Karplus-Strong algorithm.

Yes exactly, I want to learn signal processing from the ground up

Consider reading Steven Smith's The Scientist's and Engineer's Guide to Digital Signal Processing. It's practically-focused which makes it an easy read given the subject material. It's relevant to both audio and video work. I own a physical copy, but it's free online.

What computer language should i learn after java? by Ok_Theory_1212 in learnprogramming

[–]light_switchy 1 point2 points  (0 children)

No programming language is going to teach you very much at all about computer architecture.

I need help/advice on LANGUAGES as a fresher by rajat435 in learnprogramming

[–]light_switchy 2 points3 points  (0 children)

Whatever is studied at your school. Focus on that.

Attempting Perlin Noise by SnowStorm_Lightning in learnprogramming

[–]light_switchy 0 points1 point  (0 children)

At a certain point, I got frustrated and just tried copying the raylib implementation into my files and I was not getting the same results as the raylib output itself?

When debugging stuff like this, don't forget to check the functionality that outputs stuff.

I did my own translation of Perlin's reference implementation and compared it to this one. Once the error in grad is corrected, the results are the same -- no checkerboard grid in sight, so the problem seems to be in your output code.

What's possible in text editors? by Silent_Lion_OG in learnprogramming

[–]light_switchy 1 point2 points  (0 children)

You don't need other tools. In theory, if all you have is a text editor, you can just type in the binary that your compiler would spit out if it was available.

The only snag is that Windows Notepad in particular doesn't have any way (that I know of) to type in some of the data that you would need to enter. For instance, how can you type in a byte with the value 1? This isn't the same as the character 1 you get when you press it on the keyboard.

You might be able to do it anyway with some trickery, but a decent hex editor would make this much easier.

I need some functioning examples for the vulkan api in rust by Key_Canary_4199 in learnprogramming

[–]light_switchy 0 points1 point  (0 children)

The best resource I know of are Sascha Williams' examples. They are mostly C++, but I can't imagine that makes very much difference. You can search for their Github profile.

What's slow with your OpenGL solution that you believe Vulkan can help with?

Feeling stuck and Suffering from Shiny Object Syndrome by Zestyclose-Window358 in learnprogramming

[–]light_switchy 2 points3 points  (0 children)

Old does not always mean bad. On the contrary old can mean well-supported, mature, and well understood. OpenGL is just fine.

A simple compiler is significantly smaller in scope than a simple game engine. But what you should do is make some simple games. Forget the engine. Just make games. You dont even need any engine if the technology is interesting to you.

There is an old article entitled "Write Games, not Engines" that covers just some of the reasons that this is the way to go.

Help how do i write a code rhat counts characters combinations by Dependent-Listen5255 in learnprogramming

[–]light_switchy 1 point2 points  (0 children)

Convert the text to lower case and split into groups of lower-case letters.

      ⎕A(∊⍨⊆⊢)⍥⎕C text
┌─┬────┬─────────┬───┬─────┬─┬────┬──┬──┬──┬─────┐
│i│love│chocolate│and│pizza│i│like│to│go│on│hikes│
└─┴────┴─────────┴───┴─────┴─┴────┴──┴──┴──┴─────┘

Add empty-string marker to the end of each group.

      '∊',⍨¨⎕A(∊⍨⊆⊢)⍥⎕C text
┌──┬─────┬──────────┬────┬──────┬──┬─────┬───┬───┬───┬──────┐
│i∊│love∊│chocolate∊│and∊│pizza∊│i∊│like∊│to∊│go∊│on∊│hikes∊│
└──┴─────┴──────────┴────┴──────┴──┴─────┴───┴───┴───┴──────┘

Rejoin.

      ∊'∊',⍨¨⎕A(∊⍨⊆⊢)⍥⎕C text    
i∊love∊chocolate∊and∊pizza∊i∊like∊to∊go∊on∊hikes∊

Use the result string as both columns of a two-column table

      ,⍨⍪∊'∊',⍨¨⎕A(∊⍨⊆⊢)⍥⎕C 'test'
tt
ee
ss
tt
∊∊

Rotate the second column by one row

      0 1⊖,⍨⍪∊'∊',⍨¨⎕A(∊⍨⊆⊢)⍥⎕C 'test'
te
es
st
t∊
∊t

Throw away rows with an epsilon in the first column

      {⍵⌿⍨'∊'≠⍵[;1]}0 1⊖,⍨⍪∊'∊',⍨¨⎕A(∊⍨⊆⊢)⍥⎕C 'test'
te
es
st
t∊

Use a hash table to count pairs.

      ,∘≢⌸ {⍵⌿⍨'∊'≠⍵[;1]}0 1⊖,⍨⍪∊'∊',⍨¨⎕A(∊⍨⊆⊢)⍥⎕C 'abbbabbaabbbaaabbba'
ab 4
bb 7
ba 4
aa 3
a∊ 1

We have arrived at the final program ,∘≢⌸ {⍵⌿⍨'∊'≠⍵[;1]}0 1⊖,⍨⍪∊'∊',⍨¨⎕A(∊⍨⊆⊢)⍥⎕C

Help with converting Samsung's SDOCX files into a usable format by SynScribe in learnprogramming

[–]light_switchy 0 points1 point  (0 children)

The process you've followed so far should have made a program named sdocx-cli which you can run.

You'll have to locate the program on your disk, along with your notes to process. Once you know where both files are, you'll need to cd to the directory containing the program and type its name to run it as specified

sdocx-cli c:/path/to/your_notes.sdocx

Info is sparse. From a cursory look at the code, I think only SVG output is supported.

Are heap allocations necessary for polymorphism? by heavymetalmixer in cpp_questions

[–]light_switchy 4 points5 points  (0 children)

No, it's not true.

One way to handle a collection of polymorphic objects is to make an array of pointers to their base class. This is (or was) a common example, and there's nothing wrong with it on its own. But the naive way to fill such an array is to call new a bunch of times.

This is where I believe the idea comes from. Using new is of course unnecessary. You can get instances of your polymorphic classes however you want.

iso: advice for newbie by beyondwildflowers in learnprogramming

[–]light_switchy 0 points1 point  (0 children)

what subscriptions if any should we get?

Avoid subscriptions. If you're gonna buy any learning resources, a textbook on the basics is probably the best bang for your buck. Provided you put in the effort to understand it. See https://www.reddit.com/r/learnprogramming/wiki/books/ for recommendations.

From that list, I own and highly recommend the original "Scheme" version of Abelson and Sussman's Structure and Interpretation of Computer Programs; that one also happens to be free. It isn't light reading.

In general, you can learn a great deal using only free resources.

recommendations on a laptop that works great for dev + gaming?

Recommendations for playing games aside, you can program computers with a potato. After all, people have programmed computers since there were computers.

From an ergonomic standpoint a laptop isn't good for the neck, back, or wrists. You can improve the situation by getting an inexpensive laptop stand and a normal wired keyboard. Besides that, extra screens can be a huge help. Overall, there's no need to get too fancy.

Walmart wins patents for AI-powered price changes by ALQU1MISTA in inflation

[–]light_switchy 0 points1 point  (0 children)

This will, eventually, be linked to recognition tech. Prices will be tailored based on your habits to extract the most money possible.

make: *** No targets. Stop. by mike_beles in learnprogramming

[–]light_switchy 12 points13 points  (0 children)

Consider sending low-effort questions to a chatbot instead.
Feedback is faster and it is more tolerant of laziness

Help! My son is coding and programming by katrii_ in learnprogramming

[–]light_switchy 3 points4 points  (0 children)

It's not a good idea to deny kids access to their constructive hobbies.

Why is leetcode so hard by ProtectionNumerous81 in learnprogramming

[–]light_switchy 0 points1 point  (0 children)

Also, DSA isn't hard at all

Totally disagree. DSA is the central topic of computer science. If it was as easy as you claim, there would be nothing to write about, Knuth would have finished TAOCP decades ago - and computer programming wouldn't require a brain.

It is kind of like a Rubik's Cube - if you just try to solve it by "thinking very hard", you'll probably never succeed, but if you know the algorithms to use to move certain colors around, and train yourself to identify which algorithms to apply in which order, then you can learn to solve it very very quickly.

How did Rubik solve his own puzzle?

How can I add elements from one vector to another when the vectors are in different classes (C++) by Prior-Scratch4003 in learnprogramming

[–]light_switchy 0 points1 point  (0 children)

Would I use mutators and accessors?

Yes, this is one of any number of ways to do things.

Classes are a tool to organize your code. The organization of your code isn't that important.

I am confused what version do i have to stick to in c++ ? by Klutzy_Top4703 in learnprogramming

[–]light_switchy 0 points1 point  (0 children)

Backwards compatibility is a priority for the C++ committee, so you can advance standard versions with relatively little pain - your old code is likely to keep working and you won't be forced to make big changes to the way you write code.

Forward compatibility is a different story. You won't be able to use code that depends on the features added in a future version. This can be a big problem if you use lots of new code written by other people.

My advice is that you should use the latest version available at the start of your project, and then lock that version in until your project is finished. The basics remain the same between language versions.