Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 176835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:56:52+00:00 2026-05-11T13:56:52+00:00

I want a file of randomly generated positive or negative serial integers. For now,

  • 0

I want a file of randomly generated positive or negative serial integers. For now, I ask the file contain roughly (no guarantee required) equal numbers of negative and positive, but make it easy to change the proportions later. By ‘serial’, I mean the kth random negative is equal to -k, and the kth random positive is equal to +k.

This GNU Bash script one-liner would satisfy the file format, but just wouldn’t be random.

$ seq -1 -1 -5 && seq 1 5 -1 -2 -3 -4 -5 1 2 3 4 5 

This example shows what I’m looking for even better, but is still not random since the integers alternate predictably between negative and positive.

$ paste <(seq -1 -1 -5) <(seq 1 5) | tr '\t' '\n' -1 1 -2 2 -3 3 -4 4 -5 5 

Sending one of these through the shuf command makes them randomly negative or positive, but they lose their serial-ness.

$ paste <(seq -1 -1 -5) <(seq 1 5) | tr '\t' '\n' | shuf -5 4 3 2 -2 1 -1 -4 5 -3 

Note: I’m trying to test algorithms that sort lists/arrays of bits (zeros and ones), but if I use 0s and 1s I won’t be able to analyse the sort’s behaviour or tell if stability was preserved.

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:56:53+00:00Added an answer on May 11, 2026 at 1:56 pm

    Let’s start golf contest? (44)

    perl -le'print rand>.5?++$a:--$b for 1..10' 

    Edit: daotoad’s 40 chars version

    seq 1 10|perl -ple'$_=rand>.5?++$a:--$b' 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to shuffle the lines of a text file randomly and create a
I want to reach parts of a large file randomly. After opening the part
When a user selects a file, I want another file field to appear. It
ls displays the files available in a directory. I want the file names to
i want query a file xml with linq, i want get all descendat of
I want to upload file to a host by using WebClient class. I also
i want copy pdf file from application path(/data/data/package name) to sdcard.for that i have
I want to implement file uploading with behaviour which is commonly seen in various
I want a batch file which: removes a certain line [line number by %lnum%]
i want to add file(photo) to fileupload control in the c#(code behind) thanks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.