02-25-2016
There is a way to create an array of a range of random numbers with each one occurring once with no duplicates.
- Populate the first array with all possible values, call it "deck".
- Varying a (loop ) subscript from last occurrence to first, get a random number, multiply it by that subscript, and floor it to get a new subscript.
- Use the new subscript to move an item from "deck" to the loop subscript occurrence of the array "shuffle".
- Move the last active occurrence of "deck" (looping subscript) to the new subscript occurrence of deck.
When the last occurrence of deck is chosen, the last item in "deck" will be moved to its own position but, because the looping subscript is decreasing, it will never be referred to again. The array "shuffle" is now ready to use.
If the same occurrence of "deck" is chosen again, it will contain a new value.
9 More Discussions You Might Find Interesting
1. Filesystems, Disks and Memory
Hi all
I've got MacOSX server which is a UNIX based system. I've got 2 partiontion an I like to make just one partition on he disk without loosing any data on part1. Is there a way to do that kind of thing in UNIX or do I have to format everything and put up the system again?
Thanx for reading... (3 Replies)
Discussion started by: gardarm
3 Replies
2. UNIX for Dummies Questions & Answers
Hello All,
I just wanted to know what are the different ways of using commands in combination.
The most common one which i know is using pipes.
Also grouping is also done like ( ls; date) where output of both the commands is displayed.
Are there any other ways of combining various... (2 Replies)
Discussion started by: rahulrathod
2 Replies
3. UNIX for Dummies Questions & Answers
I want to show a output like this
Lee Ballancore
PID TTY TIME CMD
31799 pts/3 00:00:00 vim
31866 pts/3 00:00:00 vim
2495 pts/7 00:00:00 vim
8368 pts/0 00:00:00 vim
9544 pts/2 00:00:00 ps
Alistairr Rutherford
PID TTY TIME CMD
8368 pts/0 00:00:00 vim
9544 pts/2 00:00:00 ps
... (3 Replies)
Discussion started by: nehaquick
3 Replies
4. UNIX for Dummies Questions & Answers
Hi,
I need to delete repeated nos in a file and finally list the count. Can some one assist me?
file:
12345
12345
56345
12345
23896
Output needed:
12345
56345
23896
Total count:3
Thanks (2 Replies)
Discussion started by: gini
2 Replies
5. Shell Programming and Scripting
Hi
I have 2 files like:
file1
a 12
b 1
a 3
file2
a 9
c 0
a 8
and i would like to get
a 12 a 9
a 3 a 8
i can do it with grep and paste with 3 lines. I tried to combine using: (3 Replies)
Discussion started by: Dedalus
3 Replies
6. Shell Programming and Scripting
Hello Group,
I have a file of data that contain
1
2
3
4
5
I request you help with a shell script for generate all posible combination of these numbers with the following output:
Example:
1 + 2 + 3 + 4 + 5 =
2 + 2 + 3 + 4 + 5 =
3 + 2 + 3 + 4 + 5 =
Thanks in advance.
Carlos (7 Replies)
Discussion started by: csierra
7 Replies
7. Shell Programming and Scripting
Hi All,
Please help me in below request.
Got multiple files in a dir ex: /os . from each file need to filter based upon first field (field only has 1,2,3 or 4) and then put it in different files based on the Field 1. But need to generate a sequence while inserting and the sequence number needs... (1 Reply)
Discussion started by: rdakshn
1 Replies
8. Programming
Is there any program that can create 6 digit numbers with:
(DIGIT_1)+(DIGIT_2)+(DIGIT_3)+(DIGIT_4)+(DIGIT_5)+(DIGIT_6)=10
Any perl or C also can. Anyone can help me? Thank you (6 Replies)
Discussion started by: Tzeronone
6 Replies
9. UNIX for Beginners Questions & Answers
Good morning, In a Production environment ive seen this command that kills processes
kill -9 -1
Because i am in a production environmet i can not execute this comamnd, so i would like to know what is the difference for the conventional kill -9 PID ?
Thanks a lot (11 Replies)
Discussion started by: alexcol
11 Replies
LEARN ABOUT OPENSOLARIS
hide_panel
panel_show(3CURSES) Curses Library Functions panel_show(3CURSES)
NAME
panel_show, show_panel, hide_panel, panel_hidden - panels deck manipulation routines
SYNOPSIS
cc [ flag ... ] file ... -lpanel -lcurses [ library .. ]
#include <panel.h>
int show_panel(PANEL *panel);
int hide_panel(PANEL *panel);
int panel_hidden(PANEL *panel);
DESCRIPTION
show_panel() makes panel, previously hidden, visible and places it on top of the deck of panels.
hide_panel() removes panel from the panel deck and, thus, hides it from view. The internal data structure of the panel is retained.
panel_hidden() returns TRUE(1) or FALSE(0) indicating whether or not panel is in the deck of panels.
RETURN VALUES
show_panel() and hide_panel() return the integer OK upon successful completion or ERR upon error.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|MT-Level |Unsafe |
+-----------------------------+-----------------------------+
SEE ALSO
curses(3CURSES), panel_update(3CURSES), panels(3CURSES), attributes(5)
NOTES
The header <panel.h> automatically includes the header <curses.h>.
SunOS 5.11 31 Dec 1996 panel_show(3CURSES)