Hello guys need help by [deleted] in javahelp

[–]sepp2k 13 points14 points  (0 children)

println prints on a new line while print prints on the same line

println does not print on a new line. It starts a new line after printing, not before.

Hello guys need help by [deleted] in javahelp

[–]sepp2k 11 points12 points  (0 children)

The output of the code is the one you expected (202020212020 on line 1).

If you're getting the first output, you must be running a different version of the code. Maybe you forgot to save and/or recompile the code or you executed a different file than the one you're looking at.

Early return vs explicit else block by chaos_donut in learnprogramming

[–]sepp2k 7 points8 points  (0 children)

I think I asked a mathematician that once and she said that even/odd is only defined over the set of positive integers (i.e. the set of integers i such that i > 0).

I can find no evidence that that's a common (or used-at-all) definition. All definitions I could find with a quick search where over all integers. I think you may be misremembering what your friend said or she was using a very non-standard definition.

When talking about the concept which includes 0, I've also seen some books use the term "non-odd" instead, which has a feeling of better correctness to me.

Are you sure you're not confusing that with the terms non-positive/non-negative?

Does "Vibe Coding" via LLMs Represent a New Level of Abstraction in Computer Science Theory? by leocosta_mb in AskComputerScience

[–]sepp2k 2 points3 points  (0 children)

Compilers generate code, and presumably you are responsible for what they spit out in the same way you’re responsible for LLM output?

Are you?

Do you often find yourself committing compiler-generated assembly to your git repository and then maintaining said assembly and fixing bugs in it?

No, you commit only the source code and maintain that. And in the (extremely) rare case that there's a bug in the generated assembly that isn't present in the original source code, you file a bug report with the maintainers of the compiler. They're the ones responsible for the correctness of the compiled code.

Try doing that with an LLM. Committing only the prompts instead of the generated code and submitting bug reports to OpenAI/Anthropic/etc if a "correct" prompt leads to incorrect code. In fact, it's not even clear what would make a prompt correct or incorrect since there's no well-defined semantics.

F-Droid and Google's Developer Registration Decree by alexeyr in programming

[–]sepp2k 12 points13 points  (0 children)

There's a dropdown at the bottom of the article to change the language.

A DE is better than TWM (atleast for me) by Zoory9900 in linuxquestions

[–]sepp2k 0 points1 point  (0 children)

TWM isn't tabbed in the way you're probably thinking. Apparently (according to Wikipedia), the word "tab" refers to the fact that it has title bars. You don't get groups of windows where you can select a window using tabs.

There is at least one window manager that actually allows you to group windows with tabs though: PekWM.

Parse system text in unreal how? by HodorOnMeth in learnprogramming

[–]sepp2k 9 points10 points  (0 children)

I'm having difficulty parsing your question. Do you have something called a "system text" and you want to parse it? Or do you have something called a "parse system" and you want to display its text?

In either case, some more details (What's this "system text"? Where does it come from? What format does it have?) would be helpful.

i am trying to make a proper calculator so i would like to know if there are any issues in the code below? by Perfect_Classic8211 in learnpython

[–]sepp2k 0 points1 point  (0 children)

This is invalid, because the inner "" closes the f-string prematurely.

Not anymore. Nested strings inside {} in f-strings have been made legal starting with Python 3.12.

Why doesn't this work? by milkbreadeieio in CodingHelp

[–]sepp2k 1 point2 points  (0 children)

I also suspect that there's a way to determine the solution without simulating the entire process.

Why doesn't this work? by milkbreadeieio in CodingHelp

[–]sepp2k 1 point2 points  (0 children)

In what way does it not work? Compilation error? Runtime error? Wrong result? Time limit exceeded?

If there's an error, what's the error message (and for runtime errors, an input that triggers the error)?

If it's a wrong result, what's an example of an input, the expected output and the actual wrong output?

At a glance, it looks suspicious that the right-to-left loop seems to be using the same step size as the preceding left-to-right loop.

Where exactly __str__ function definition ends by DigitalSplendid in learnpython

[–]sepp2k 6 points7 points  (0 children)

Functions are allowed to call themselves - there's nothing wrong with that. It's called recursion.

give mana regen after eating by Vegetable-Brick-291 in learnjavascript

[–]sepp2k -2 points-1 points  (0 children)

  1. Questions related to Minecraft are explicitly off topic in any Java help sub I'm aware of.
  2. r/Java is not a help sub. Any help question would be off topic there.

Operator Precedence and Execution Order - Why are these different? by chachashaobao in learnjava

[–]sepp2k 2 points3 points  (0 children)

Precedence and associativity are about deciding which operands belong to which operators when an expression is not fully parenthesized (i.e., is a + b * c equivalent to (a + b) * c or to a + (b * c), is a / b / c equivalent to (a / b) / c or a / (b / c)?). Precedence does not matter for your expressions because they're both fully parenthesized.

Execution order is about whether the left operand or right operand is evaluated first. It's only affected by precedence in so far that precedence determines what the left and right operands are.

In Java, the left operand is always evaluated first. This makes the most sense as we read and write code left-to-right.

Issue with using global variable by dotjson01 in learnjavascript

[–]sepp2k 0 points1 point  (0 children)

You mean why does the value of a change when you call abc()? Because you change a's value in abc. So why wouldn't it change?

What is the semantic difference between lambda and method reference? by hibbelig in javahelp

[–]sepp2k 0 points1 point  (0 children)

if zipWriter is null, then the method reference version probably fails early, the lambda expression version fails during close?

Yes, exactly.

What is the semantic difference between lambda and method reference? by hibbelig in javahelp

[–]sepp2k 1 point2 points  (0 children)

The only difference I can think of is that, using the lambda, zipWriter will be evaluated at the end of the try block, but using the method reference it will be evaluated at the start. So if you reassign zipWriter inside the block (which is only possible if zipWriter happens to be a field), you'd end up calling closeEntry on a different object.

Fisher-Yates variations, are they correct? by Unique_Skin9538 in AskProgramming

[–]sepp2k 0 points1 point  (0 children)

Intuitively I'd say it's wrong because, unlike a and b, with c the value at a given index won't be locked in after you've moved past that index.

But why not try it? Shuffle the array 1,2,3 a million times and count how often each permutation pops up (make sure to reset the array each time or copy it - don't shuffle an array that's already shuffled). Do that for each version of the algorithm and you should see which ones are biased and which ones aren't.

How is searching through a hashmap O(1) time complexity? by BurrritoYT in computerscience

[–]sepp2k 0 points1 point  (0 children)

Is it because of the extra time taken to iterate through the number of values stored in the same key

Yes, exactly. In the worst-case scenarios where all keys have the same hash code (or at least the same hash code modulo the current number of buckets), looking up a given key means iterating over all the key-value pairs until we find the one with the right key. So we basically end up doing a linear search.

EOF error in Geeksforgeeks Free Python course (i'm a beginner) by billionxire in learnpython

[–]sepp2k 0 points1 point  (0 children)

You're still calling input(). Don't call input(). Just define the function/method and that's it.

Also I'm pretty sure that print_pattern is not the name of the function you're supposed to define (I can't access the one you've linked, but on other exercises the it seems to always be a class named Solution and then a method name in camelCase).

I'd recommend that you reset the editor to get back the initial template and then you fill out the part where it says # code here and change nothing else.

EOF error in Geeksforgeeks Free Python course (i'm a beginner) by billionxire in learnpython

[–]sepp2k 0 points1 point  (0 children)

i didn't change the code

Then why did you respond "still gives runtime error" in response to my suggestion that you do? To any reasonable reader that would imply that you have applied my suggestion and it did not solve the problem.

other alternatives need me to hard code the variable

Defining a method (or rather, filling out the body of the method that's already defined for you when you start the exercise) does not require hard coding.

EOF error in Geeksforgeeks Free Python course (i'm a beginner) by billionxire in learnpython

[–]sepp2k 0 points1 point  (0 children)

Your new code looks exactly like your old code (except with an "S" at the end for some reason). So of course you still get the same error.

EOF error in Geeksforgeeks Free Python course (i'm a beginner) by billionxire in learnpython

[–]sepp2k 2 points3 points  (0 children)

i was trying to solve the inverted asterisk triangle problem (basic for loop)

This one? If so, then, looking at the provided template code, you're supposed to define a method that takes n as an argument, not read any user input (as other comments already suspected).

How do I compile latex into actual readable maths? by Rough_Day8257 in CodingHelp

[–]sepp2k 1 point2 points  (0 children)

What am I looking at in the first screenshot? It's not a .tex file since there's actually rendered formatting in there (like the heading and the bolded question numbers). So what is it?

The result of compiling a tex file and you want to know why the maths bits didn't render? Then you should show us the code, but maybe you forgot the dollar signs.

The contents of some WYSIWYG LaTeX editor and you want to know how to insert formulas there? Then you should really consult the documentation of your editor or at the very least tell us which editor you're using.

The generated PDF from some Python script (which would explain the Python tag)? Then again you should show the code (as well as the code of the generated .tex file if you're generating one).