Skip to content

Conversation

@casey
Copy link
Collaborator

@casey casey commented May 20, 2025

This is just a draft PR. I'd like to make this more comprehensive:

  • Assign unique luck scores to each digit, not just four and eight. Will require a consultation with a feng shui expert.
  • Display digits in both 大寫 and 小寫
  • Consider a more mathematically complex scheme for calculating the luck score. For example, the place of the digit could contribute to the luck score, with leftmost digits contributing more and right most digits contributing less. An example of an interesting scheme is a balanced-base-B polynomial. Big-place digits act like Heavenly Mandates dominating lesser earthly whispers below.
  • Use a bijective mapping?
  • Use 60ths because of https://en.wikipedia.org/wiki/Sexagenary_cycle
  • Should repeated digits magnify the effect of the digit?

Sources:

@cbspears
Copy link
Contributor

Bro

@encloinc
Copy link

LGTM

@DrJingLee
Copy link
Contributor

image

A number system from 1-64 ?

@FoodGoods
Copy link

Systemic lens needed

@DrJingLee
Copy link
Contributor

Casey: I think this is very interesting topic but the code is still a bit oversimplified, if it just counting the lucky value of 8s and 4s. For example, a sat number like 8888844444 is obviously a great and lucky number, but its lucky value is only 0.

There are many ways to play with the lucky value of numbers, but it seems there aren’t many that achieve widespread consensus. For instance, one method is to add up all the digits of a sat number, repeating the process until you get a single digit. Take 88884444: the calculation would be 8+8+8+8+4+4+4+4=48, then 4+8=12, and finally 1+2=3.

Another approach involves combinations with Chinese phonetic associations, like 520 1314 etc. In China, phone numbers with lucky digits are often considered special and can be sold at a higher price or even auctioned off. It’s definitely a fascinating topic.

@casey
Copy link
Collaborator Author

casey commented May 22, 2025

Casey: I think this is very interesting topic but the code is still a bit oversimplified, if it just counting the lucky value of 8s and 4s. For example, a sat number like 8888844444 is obviously a great and lucky number, but its lucky value is only 0.

This is really good feedback. So the presence of a run of 4s doesn't reduce the luckiness? What about this number: 4444488888 Lucky or unlucky?

We could weight the luck value of a digit by its position in the number.

There are many ways to play with the lucky value of numbers, but it seems there aren’t many that achieve widespread consensus. For instance, one method is to add up all the digits of a sat number, repeating the process until you get a single digit. Take 88884444: the calculation would be 8+8+8+8+4+4+4+4=48, then 4+8=12, and finally 1+2=3.

This wouldn't be great, since it would mean that every sat would have one of ten luck values, which is boring.

Another approach involves combinations with Chinese phonetic associations, like 520 1314 etc. In China, phone numbers with lucky digits are often considered special and can be sold at a higher price or even auctioned off. It’s definitely a fascinating topic.

This is good, but too subjective, since you would have to come up with a list of phonetic associations which would change over time.

@DrJingLee
Copy link
Contributor

Casey: I think this is very interesting topic but the code is still a bit oversimplified, if it just counting the lucky value of 8s and 4s. For example, a sat number like 8888844444 is obviously a great and lucky number, but its lucky value is only 0.

This is really good feedback. So the presence of a run of 4s doesn't reduce the luckiness? What about this number: 4444488888 Lucky or unlucky?

We could weight the luck value of a digit by its position in the number.

Yeah , the position of digit matters.I'm trying to rank the luck values of permutations of three 8s and three 4s. There are 20 different combinations in total, and based on my intuition, the top lucky numbers can be.

Number Ranks Type
444888 1 AAABBB
888444 2 BBBAAA
484848 3 ABABAB
848484 4 BABABA
448848 5 8848 is unique height of himalaya

844488
448488
484488
884448
844848
488448
848448
884844
488844
848844
844884
884484
488484
484884
448884

Based on observing the intuitive ranking, the following simple rules may be summarized:
Within the same type, numbers ending with 8 have a higher luck value than those ending with 4. The weight for ending with 8 can be 10, while the weight for ending with 4 can be -10.

In terms of the order of number permutations, it seems: AAABBB type > ABABAB type > special meaning (8848) > other miscellaneous permutations.

Certain special number combinations (e.g., 8848) may be ranked higher due to cultural or symbolic significance.

There are many ways to play with the lucky value of numbers, but it seems there aren’t many that achieve widespread consensus. For instance, one method is to add up all the digits of a sat number, repeating the process until you get a single digit. Take 88884444: the calculation would be 8+8+8+8+4+4+4+4=48, then 4+8=12, and finally 1+2=3.

This wouldn't be great, since it would mean that every sat would have one of ten luck values, which is boring.

Another approach involves combinations with Chinese phonetic associations, like 520 1314 etc. In China, phone numbers with lucky digits are often considered special and can be sold at a higher price or even auctioned off. It’s definitely a fascinating topic.

This is good, but too subjective, since you would have to come up with a list of phonetic associations which would change over time.

@DrJingLee
Copy link
Contributor

A sample RUST code after 30 minutes discussion with GROK ,seems good to my understanding.
see if this could help a little bit :

=================================================================================

use regex::Regex;
use std::collections::HashMap;
use std::cmp::{max, min};

// Evaluates the lucky value of a number string based on Chinese cultural rules
// Returns: (raw score, normalized score [0-10], explanation) or an error message
fn evaluate_lucky_number(number_str: &str) -> Result<(i32, f64, String), String> {
// Validate input: ensure it's all digits
if !number_str.chars().all(|c| c.is_digit(10)) {
return Err("Input must be purely numeric!".to_string());
}

let n = number_str.len();
let mut score = 0;
let mut explanations = Vec::new();

// 1. Lucky digit weights
let lucky_weights: HashMap<char, i32> = [
    ('8', 10), // "Fa" (prosperity), most lucky
    ('6', 8),  // "Liu" (smooth), very lucky
    ('9', 6),  // "Jiu" (long-lasting), lucky
    ('3', 4),  // "Sheng" (growth), moderately lucky
    ('1', 2),  // Neutral, slight positive
    ('2', 2),  // Neutral, harmony
    ('5', 2),  // Neutral, "Wu" (five blessings)
    ('0', 1),  // Neutral, completeness
    ('7', -2), // Sometimes unlucky (e.g., "Qi Chu")
    ('4', -10), // "Si" (death), most unlucky
].iter().cloned().collect();

// Count occurrences of each digit
let mut digit_counts = HashMap::new();
for c in number_str.chars() {
    *digit_counts.entry(c).or_insert(0) += 1;
}

// Calculate score based on digit weights
for (&digit, &count) in &digit_counts {
    let digit_score = count * lucky_weights.get(&digit).unwrap_or(&0);
    score += digit_score;
    if digit_score > 0 {
        explanations.push(format!("Digit {} appears {} times, adds {} points (lucky)", digit, count, digit_score));
    } else if digit_score < 0 {
        explanations.push(format!("Digit {} appears {} times, subtracts {} points (unlucky)", digit, count, digit_score.abs()));
    }
}

// 2. Rarity: consecutive repeating digits
let re = Regex::new(r"(\d)\1+").unwrap();
for cap in re.captures_iter(number_str) {
    let repeat = cap.get(1).unwrap().as_str().chars().next().unwrap();
    let length = cap.get(0).unwrap().as_str().len() as i32;
    let repeat_score = length * if "8693".contains(repeat) { 5 } else { 2 };
    score += repeat_score;
    explanations.push(format!("Found consecutive {} ({} times), adds {} points (rarity)", repeat, length, repeat_score));
}

// 3. Rarity: symmetry (e.g., 686)
if n > 1 && number_str == number_str.chars().rev().collect::<String>() {
    let symmetry_score = n as i32 * 3;
    score += symmetry_score;
    explanations.push(format!("Number {} is symmetric, adds {} points (rarity)", number_str, symmetry_score));
}

// 4. Rarity: ascending/descending sequence (e.g., 123, 987)
let mut chars: Vec<char> = number_str.chars().collect();
chars.sort();
let sorted_str: String = chars.into_iter().collect();
let mut chars: Vec<char> = number_str.chars().collect();
chars.sort_by(|a, b| b.cmp(a));
let reverse_sorted_str: String = chars.into_iter().collect();
let unique_count = number_str.chars().collect::<std::collections::HashSet<char>>().len();

if number_str == sorted_str && unique_count == n {
    let sequence_score = n as i32 * 4;
    score += sequence_score;
    explanations.push(format!("Number {} is ascending, adds {} points (rarity)", number_str, sequence_score));
} else if number_str == reverse_sorted_str && unique_count == n {
    let sequence_score = n as i32 * 4;
    score += sequence_score;
    explanations.push(format!("Number {} is descending, adds {} points (rarity)", number_str, sequence_score));
}

// 5. Specific lucky/unlucky combinations
let lucky_patterns: HashMap<&str, (i32, &str)> = [
    ("168", (20, "All the way to prosperity")),
    ("518", (15, "I will prosper")),
    ("666", (15, "Very smooth")),
    ("888", (20, "Triple prosperity")),
    ("520", (10, "I love you")),
].iter().cloned().collect();

let unlucky_patterns: HashMap<&str, (i32, &str)> = [
    ("14", (-15, "To die")),
    ("47", (-15, "Death period")),
].iter().cloned().collect();

for (pattern, &(pattern_score, meaning)) in &lucky_patterns {
    if number_str.contains(pattern) {
        score += pattern_score;
        explanations.push(format!("Contains {} ({}), adds {} points", pattern, meaning, pattern_score));
    }
}

for (pattern, &(pattern_score, meaning)) in &unlucky_patterns {
    if number_str.contains(pattern) {
        score += pattern_score;
        explanations.push(format!("Contains {} ({}), subtracts {} points", pattern, meaning, pattern_score.abs()));
    }
}

// 6. Length bonus
let length_bonus = n as i32 * 2;
score += length_bonus;
explanations.push(format!("Number length {}, adds {} points (complexity)", n, length_bonus));

// 7. Normalize score to 0-10
let min_score = (n as i32 * -10) + (n as i32 / 3) * -15; // All 4s + unlucky patterns
let max_score = (n as i32 * (10 + 5)) + (n as i32 / 3) * 20 + (n as i32 * 2); // All 8s + repeats + lucky patterns + length
let normalized_score = if max_score == min_score {
    5.0
} else {
    ((score - min_score) as f64 / (max_score - min_score) as f64) * 10.0
};
let normalized_score = max(0.0, min(10.0, normalized_score));

// Ensure raw score is non-negative
let score = max(0, score);

explanations.push(format!(
    "Normalized lucky value: {:.2}/10 (raw score {}, min possible {}, max possible {})",
    normalized_score, score, min_score, max_score
));

Ok((score, normalized_score, explanations.join("\n")))

}

fn main() {
// Placeholder for user input
let number = "888888 "; // Replace with your input sat number
match evaluate_lucky_number(number) {
Ok((score, normalized_score, explanation)) => {
println!("Number: {}", number);
println!("Raw lucky value: {}", score);
println!("Normalized lucky value: {:.2}/10", normalized_score);
println!("Evaluation details:");
println!("{}", explanation);
}
Err(e) => println!("Error: {}", e),
}
}

@DrJingLee
Copy link
Contributor

This is just a draft PR. I'd like to make this more comprehensive:

  • Assign unique luck scores to each digit, not just four and eight. Will require a consultation with a feng shui expert.
  • Display digits in both 大寫 and 小寫
  • Consider a more mathematically complex scheme for calculating the luck score. For example, the place of the digit could contribute to the luck score, with leftmost digits contributing more and right most digits contributing less. An example of an interesting scheme is a balanced-base-B polynomial. Big-place digits act like Heavenly Mandates dominating lesser earthly whispers below.
  • Use a bijective mapping?
  • Use 60ths because of https://en.wikipedia.org/wiki/Sexagenary_cycle
  • Should repeated digits magnify the effect of the digit?

Sources:

Check dis https://x.com/i/grok/share/da3qzHWuYHxkYABZt9BbeZZxy 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants