kambar bek

Greenhorn
+ Follow
since Apr 19, 2010
kambar likes ...
Eclipse IDE Python Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
8
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by kambar bek

can i delete my profile completely? i dont' plan to use it. I have not used it that much.

please delete my profile
8 years ago
I learned this technique from a TA in college, it is called "using indicator variable" and the name pretty much says the essence of this technique.

the program below is coding bat exercise.i solved it

the question itself:

Return the sum of the numbers in the array, except ignore
sections of numbers starting with a 6 and extending to
the next 7 (every 6 will be followed by at least one 7).
Return 0 for no numbers.







Question:
1.is there other technique to avoid using "indicator variable" trick?
2.I suspect it is not "design patterns " that explains these little tricks. but I need to know all those little things.

what is the part of software development that describes these tricks/techniques to newbies? how is it called?
3. what books are there that give you list of those little techniques? or maybe tutorials? anything would be great! recommendations?

P.S. i would not be able to solve this problem another way , if i did not know indicator variable thing! So i want to know other ways of solving this problem!
11 years ago
does "continue " keyword have any effect here in this program?



is it diff. from the exact same program that does not have "continue" ?
11 years ago
Hi, i have been solving codingbat exercises in java.

I consider myself a beginner and quite often i have to write each iteration with pen/paper to understand what i am doing, especially when using loops and recursion

as a wanna-be-efficient programmer, i suspect it is possible to automate this process,i.e. write some applet or function that you can give parameters and it will go through array/string and highlight every comparison/check step-by-step.

I already tried to google it, but did not find much, only this:http://en.wikipedia.org/wiki/File:Quicksort-example.gif


is there any educational applet/program that you can give parameters like array to go through, operation to do and it will highlight and show slow /fast speed visualization?

Question:
1. do you know software/applet that does it?
2. if not, this could be another idea - write my own project for myself/educational purposes; in this case, how can i do this?
11 years ago
I m used to see objects created in java like this:





questions:

what does it mean when we create object like in * - this nested thing?

can we do something like this:


DisplayTime x = new DisplayTime(new Calendar(new Player(new Gambler(new Weather(...............))))) - and so on?

if yes, how many times can we nest it? and what does it mean if i see 3 or more objects created, nested in each other?

i m really confused about what created where / who creates what

can someone explain?
11 years ago
I m doing coding bat exercises;

to do debugging - i add many System.out.println() statements,

i m tired of writing it many times.


My question:

is there a shortcut or quick way to write this print statement quickly? if so, how?

hi , i ve been programming for 3 years now , but i still have this question:

suppose my code looks like this:




how is code above diff from this below:



is there any difference? i suspect no
11 years ago
actual question:
Given two strings, return true if either of the strings appears at the very end of the other string, ignoring upper/lower case differences (in other words, the computation should not be "case sensitive"). Note: str.toLowerCase() returns the lowercase version of a string.

endOther("Hiabc", "abc") → true
endOther("AbC", "HiaBc") → true
endOther("abc", "abXabc") → true

my solution:




===============================================
i m 90% sure this code can be simplified, but i don't know other logic or way of thinking about this simple exercise

can someone help me refactor it and make it smaller?
11 years ago
thanks guys, it was silly mistake


i found it after i did it


thanks every1
11 years ago
hi , i m doing coding bat exercises in java.
the question :

Given a string, if the first or last chars are 'x', return the string without those 'x' chars, and otherwise return the string unchanged.

withoutX("xHix") → "Hi"
withoutX("xHi") → "Hi"
withoutX("Hxix") → "Hxi"

my solution:


what i don't get is why it never goes to * part of code

for example if the string given is "xHix" , it only deletes last x , but the first x is still there ,
and it gives wrong answer "xHi", but it should delete the first "x"

11 years ago
i realized the naming for variables is not good enough, i used too many "number" in methods and variable names, (((

but it is ok, i m done anyways! ))

[Erjan Kenjegalee, please do not use profanity in your posts here. I have removed the offending word.]
12 years ago
thanks to everyone posted in this topic, i got it done, using NUMERIC approach, and using / and % as the exercise tells us

i needed to know how many digits the given number has, so i wrote the method for this.



again, thanks to all of you guys, one more exercise is done! )))
12 years ago
i need to write method displayDigits that displays digits with 2 spaces between each digit

e.g. 4562 should be "4 5 6 2"

method accepts digits in range 1 - 99999, i have it done, but i implemented the code in a "stupid manner"

I have WORKING CODE , how do i refactor it to use while loop?

12 years ago
the code below generates a question on number multiplication (inside applet)
e.g. - "what is 5 times 6"

the user enters answer and clicks button - if he is right, "very good " is displayed and a new string (question) is shown
or "try again" is shown and he has to answer it again


this is a WORKING CODE, i only need to make generate_question() and check_answer() methods to get called from paint() method

I DON'T HAVE paint() coded yet - i m asking you guys how to do it?

paint() should look like this - paint(Graphics g) {......}

-------------------------------------
Java how to program chapter 6, 4ed, ex 6.31

12 years ago
i m writing a java applet that accepts 4 parameters to draw a rectangle - x, y, width, height

my problem is, i don't know how to call it in another method - square of asterisks,

it needs a variable Graphics g to be supplied, but i don't know where to give this "g" variable!



here is the problem, how to initialize Graphics g variable?

12 years ago