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

  • Home
  • SEARCH
  • 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 8909089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:20:52+00:00 2026-06-15T03:20:52+00:00

First off, let me warn you that my Maths knowledge is fairly limited (hence

  • 0

First off, let me warn you that my Maths knowledge is fairly limited (hence my coming here to ask about this).

It’s a silly example, but what I essentially want is to have a variable number of rows, and be able to set a maximum value, then for each progressive row decrease that value until half way at which point start increasing the value again back up to the maximum by the final row.

To illustrate this… Given that: maxValue = 20, and rows = 5, I need to be able to get to the following values for the row values (yes, even the 0):

row 1: 20
row 2: 10
row 3: 0
row 4: 10
row 5: 20

There are limitations though because I’m trying to do this in Compass which uses SASS. See here for the available operations, but to give you the gist of it, only basic operations are available.

I’m able to loop through the rows, so just need the calculation that will work for each individual row in the series. This is the kind of loop I’m able to use:

$maxValue:20;
$rows:5;

@for $i from 1 through $rows {
    // calculation here.
}
  • 1 1 Answer
  • 0 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. Editorial Team
    Editorial Team
    2026-06-15T03:20:53+00:00Added an answer on June 15, 2026 at 3:20 am

    I haven’t really worked with SASS before, but try something like this using a basic if and the floor function, not sure if will work

    // set various variables
    $maxValue:20;
    $rows:5;
    // get row number before middle row, this instance it will be 2
    $middleRow = floor( $maxValue / $rows )
    // get increment amount, this instance should be 10
    $decreaseValue = ( max / floor( rows / 2) )
    
    @for $i from 0 through $rows - 1 {
    
       @if $i <= $middleRow {
    
          ( $maxValue- ( $decreaseValue * $i ) )
    
        }
    
       @else{
    
        // times by -1 to make positive value
           ( $maxValue - ( $decreaseValue * -$i ) ) * -1
    
        }
    }
    

    I have tested the above in js ( with relative syntax ) and it yielded the required results ( jsBin example ). Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, let me explain that I am well aware of what this exception
First off, let me say that this is not homework (I am an A-Level
First off, let me preface this question by saying that my professor is firmly
First off, let me preface this question by stating that I'm really a pretty
First off, let me start by saying that I am totally new to working
First off, let me apologize if I'm writing this in the wrong place. I
First off, let me apologize if this has been asked already, but I can’t
let me first off noting that I have absolutely no idea what I'm doing
First off let me apologize to the SO community for coming to you with
First off, I don't know if this is possible, but let me describe my

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.