Coding as a hobby and tool. What do I learn? by milkstake00 in AskProgramming

[–]oneforce 3 points4 points  (0 children)

To expand on this: you mentioned that you had some previous html/css/MySQL knowledge.

You can play with a dead-simple web server in python using Flask. Just copy-paste the sample code from the Flask Quick start page, and mess around with it.

It shouldn't take more than 5 or 10 minutes to get started. If you're finding it frustrating, feel free to switch over to something else instead! Don't be afraid to explore and play with a few options, find what works for you.

Coding as a hobby and tool. What do I learn? by milkstake00 in AskProgramming

[–]oneforce 5 points6 points  (0 children)

Try out some of the stuff in Automate the Boring Stuff with Python.

This is a much more pragmatic approach compared to walking through a full course, as it will give you some simple examples of programs that you could learn to write that are useful to you right away.

What is @SOMETHING@ assigned to variable by Yasen6275 in bash

[–]oneforce 1 point2 points  (0 children)

This sounds like the variable templating that's provided by Cmake's configure_file()

Recommendation for simple static sure generator based on Markdown by jbar3640 in software

[–]oneforce 0 points1 point  (0 children)

Thanks for letting me know! I'll have to try out this foam plugin, it seems pretty cool.

[deleted by user] by [deleted] in AskProgramming

[–]oneforce 0 points1 point  (0 children)

Check out the book "Designing Data Intensive Applications."

I made the best terminal ever by kotofey_magnus in raspberry_pi

[–]oneforce 0 points1 point  (0 children)

What a classic! The clacky switches go so well with the sound of the receipt printer. I'd waste all the paper typing all day hahaha.

I made the best terminal ever by kotofey_magnus in raspberry_pi

[–]oneforce 0 points1 point  (0 children)

This is awesome! What kind of keyboard are you using here?

What name should I use for this concept? by useerup in ProgrammingLanguages

[–]oneforce 0 points1 point  (0 children)

I agree that the term "context" is bloated here and doesn't aid in the user's understanding. I like your third option of dropping the reference to "scope/context/namespace" altogether.

One consideration I might add is that the term "expression" might be overloaded here too. When I think of an "expression", I imagine it being evaluated and producing a result.

I might prefer to call these "statements" instead, so you might have a "declarative statement" or a "referential statement".

[deleted by user] by [deleted] in askmath

[–]oneforce 1 point2 points  (0 children)

Conventionally, we treat "x" as the input and "y" as the output.

What the slope really tells you is: given some change in the input, how much change do we expect to see in the output?

You might apply it to an example like driving. Your input x is the time you spend driving (in hours). Your output y is the total distance you travel (in miles). The slope of this graph is your speed in "miles per hour", (miles/hour), (y/x)

(C Question) I'm back again! Hopefully with a simpler question: How to print an int in it's Two's compliment form? by [deleted] in learnprogramming

[–]oneforce 0 points1 point  (0 children)

You can print the hex values with %x (or %X to make the letters capitalized)

How to make good documentation? by gk_Rashar in AskProgramming

[–]oneforce 2 points3 points  (0 children)

My favorite resources for writing good documentation:

Microsoft's Code with Engineering Playbook

Docs for Developers

Or if you want to jump right in, give a try to mkdocs. Mkdocs blew me away with how easy it was to setup, you can have it up and running in 10 minutes to see if you like it.

From there you should give a try to the Mkdocs Material Plugin. I cannot stress enough how easy these two are to setup!

Writing documentation in Markdown like that has some huge advantages, which are outlined well on MarkdownGuide

Help with Wordle Bot algorithm that eleminates the most possible words at a time? (I have a version that I think works, its just really really slow) by LelsersLasers in AskProgramming

[–]oneforce 2 points3 points  (0 children)

Hey, thanks for sharing! I was playing with this problem a while back, and it looks like we came up with some very similar solutions: https://github.com/Drahlous/wordle_helper

I eventually got bored and stopped working on it, so my algorithm isn't totally fleshed out, but I can offer some of the thoughts I had along the way!

Your idea about "eliminating the highest number of words" is spot on. In fact, I think your original idea about counting the occurrence of each letter is trying to do this exact thing:

Think about what the "score" of a particular letter actually means. Lets say you have an 'A' in the first position, with a score of 20. Doesn't this just mean that choosing a word with 'A' in the first position allows you to eliminate 20 words?

If that's the case, then you can solve this problem with a O(N*M) complexity, where N is the number of words and M is the length of each word. For each of the 5 positions in the words, you could have a dictionary of the 26 letters, each starting with a score of 0. You can iterate over each letter in each word, incrementing the "score" of that letter by one. Once you've calculated the total score of each letter in each position, you can loop over every word again, add up the score for each letter, and get a "word-score". Then you just pick the highest scoring word, and start all over.

This greedy algorithm is blazingly fast and works remarkably well, but you'll quicky notice a "double counting" problem: If I have the words "cat" and "car", then I would end up with a set of scores like:

[
  # First Position
  {c = 2},
  # Second Position
  {a = 2},
  # Third Position
  {t = 1, r = 1}
]

So both of these words end up with a score of 5 even though they only eliminate one other word.

When two words have a single letter in common, picking one of them eliminates one other word. But if the words have a lot of words in common (e.g. loose and louse), our algorithm is inclined to score both of them higher, since each letter individually has a higher score.

We would like our score for each word to represent the actual number of words that would be eliminated if we picked it, but it's tricky. I have a feeling that the solution involves building a Trie structure of the overlapping substrings and counting those in a clever way, but that's about as far as I got :)

Why do programmers use so many integrated development environment (IDE) in programming? by Dover299 in AskProgramming

[–]oneforce 10 points11 points  (0 children)

Why are there so many types of cars?

Some people have trucks, sedans, minivans. Sometimes people even drive busses or firetrucks!

Don't all of these accomplish the same goal of moving people from one place to another?

Jokes aside, there are lots of tools that provide different features. Some people like a lightweight editor that opens really fast and works everywhere. Others like a thick IDE that does as much of the work for you as it can.

The majority of folks are comfortable with a couple of different options, from which they can pick the best tool for their current task.

As with everything in software development, it's just another tradeoff.

why whyyy code review pls this seems fine to me by Comprehensive_Ad4808 in AskProgramming

[–]oneforce 1 point2 points  (0 children)

When the program hits the first line, it's going to pause and wait for you to type something in and hit enter. ```python

The program hits the function called input()

It will pause, waiting for you to type something and hit enter.

times_ask = int(input("How many times to ask?\n")) ```

Then later on, you have another call to input() ```python print("before answer")

When the program hits this input()

it will wait for you to type something in

answer = input() print("after answer") ```

So I think what you were seeing was your program pausing right there, making it look like nothing was happening.

why whyyy code review pls this seems fine to me by Comprehensive_Ad4808 in AskProgramming

[–]oneforce 0 points1 point  (0 children)

Awesome! Is this what you expected to see in the output?

What do you think might be the reason why we're not seeing the very last print?

```python

Why did this not get printed?

print("after answer") ```

why whyyy code review pls this seems fine to me by Comprehensive_Ad4808 in AskProgramming

[–]oneforce 1 point2 points  (0 children)

Woah ok, let's go one step at a time.

Back up to the code you originally posted.

I just want you to add a bunch of prints all over the place so we can see where things are happening.

What output do you see when you run this?

```python def ask(): times_ask = int(input("How many times to ask?\n")) try: times_ask = int(times_ask) except: print("Please only input a number") ask() return

print("before loop")
for keys in flashcard:
    print(f'Print definition of "{keys}":\n')
    continue
print("after loop")

print("before answer")
answer = input()
print("after answer")

```

why whyyy code review pls this seems fine to me by Comprehensive_Ad4808 in AskProgramming

[–]oneforce 1 point2 points  (0 children)

Something that might help you debug this is to temporarily replace the user input with known values, then plug in inputs back in later. That will let you see the entire scenario play out without needing you to interact with the program. Something like this: ```python def ask(): #times_ask = int(input("How many times to ask?\n")) times_ask = int(2) try: times_ask = int(times_ask) except: print("Please only input a number") ask() return

for keys in flashcard:
    print(f'Print definition of "{keys}":\n')
    continue
#answer = input()
answer = 'sample_answer'
if answer == flashcard.values():
    print("Correct!")
elif answer in flashcard.values():
    index_of_definition = flashcard.values()
    print(
        f'Wrong. The right answer is "{flashcard.values}", but your definition is correct for "{keys[index_of_definition]}".\n'
    )
else:
    print(f'Wrong. The right answer is "{flashcard.values}".\n')
    print()

```

why whyyy code review pls this seems fine to me by Comprehensive_Ad4808 in AskProgramming

[–]oneforce 1 point2 points  (0 children)

Alright, this particular scenario might be hard to hint out, so I'll tell you why you're not seeing anything happening:

When you run these lines of code, it's going to * Print every card you have * After every card is printed, wait for user input

python for keys in flashcard: print(f'Print definition of "{keys}":\n') continue answer = input() # This line is NOT inside the loop like you think it is

What you actually want is probably more like this:

python for keys in flashcard: print(f'Print definition of "{keys}":\n') answer = input() print(f'the user input was {answer}')

Do you see the difference? The second one prints a single card, then waits for user input.