From 3143e5964b2025edaafa998941108ca36e681c84 Mon Sep 17 00:00:00 2001 From: Tao Tien <29749622+taotien@users.noreply.github.com> Date: Sat, 14 Feb 2026 20:05:04 -0800 Subject: [PATCH] --- Cargo.lock | 8 +++++++- jiang/Cargo.toml | 1 + jiang/src/lib.rs | 16 +++++----------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a86ab2..8df40c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1229,7 +1229,6 @@ dependencies = [ "bitflags 2.10.0", "color-eyre", "ratatui", - "smol_str", "tracing", ] @@ -3338,6 +3337,12 @@ dependencies = [ "byteorder", ] +[[package]] +name = "hashbag" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7040a10f52cba493ddb09926e15d10a9d8a28043708a405931fe4c6f19fac064" + [[package]] name = "hashbrown" version = "0.12.3" @@ -3715,6 +3720,7 @@ checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" name = "jiang" version = "0.1.0" dependencies = [ + "hashbag", "jong-types", ] diff --git a/jiang/Cargo.toml b/jiang/Cargo.toml index eb1b523..eeb2ed3 100644 --- a/jiang/Cargo.toml +++ b/jiang/Cargo.toml @@ -4,4 +4,5 @@ version = "0.1.0" edition = "2024" [dependencies] +hashbag = "0.1.13" jong-types.workspace = true diff --git a/jiang/src/lib.rs b/jiang/src/lib.rs index 89010fc..2a698f7 100644 --- a/jiang/src/lib.rs +++ b/jiang/src/lib.rs @@ -1,11 +1,11 @@ use std::collections::HashMap; +use hashbag::HashBag; use jong_types::*; // pub fn check_valid() {} pub enum Meldable { - Ron, Chii(Tile, Tile), Pon, Kan, @@ -52,17 +52,11 @@ pub fn find_meldables(hand: &[Tile], dealt: Tile) -> Vec { calls.push(Meldable::Chii(prev_outer, prev_inner)); } - // find ron - calls } -fn count_shapes(hand: &[Tile]) { - let hand = if !hand.is_sorted() { - let mut hand = hand.to_vec(); - hand.sort(); - &hand - } else { - hand - }; +pub fn check_ron(hand: &[Tile], melds: &[&[Tile]]) { + let bag: HashBag = HashBag::from_iter(hand.iter().cloned()); + + }