Lemmy doesn't handle certain characters well currently such as left angle brackets and ampersands due to some sanitization in the back end to stop scripting attacks
[Rust] Harder one today, for part 1 I ended up getting stuck for a bit since I wasnt taking numbers at the end of lines into account and in part 2 I defined my gears vector in the wrong spot and spent a bit debugging that
Code
(lemmy removes some chars, all chars are in code link)
use std::fs;
fn part1(input: String) -> u32 {
let lines = input.lines().collect::>();
let mut sum = 0;
for i in 0..lines.len() {
let mut num = 0;
let mut valid = false;
let chars = lines[i].chars().collect::>();
for j in 0..chars.len() {
let character = chars[j];
let parts = ['*', '#', '+', '$', '/', '%', '=', '-', '&', '@'];
if character.is_digit(10) {
num = num * 10 + character.to_digit(10).unwrap();
if i > 0 {
if parts.contains(&lines[i - 1].chars().collect::>()[j]) {
valid = true;
}
if j > 0 {
if parts.contains(&lines[i - 1].chars().collect::>()[j - 1]) {
valid = true;
}
}
if j < chars.len() - 1 {
if parts.contains(&lines[i - 1].chars().collect::>()[j + 1]) {
valid = true;
}
}
}
if i < lines.len() - 1 {
if parts.contains(&lines[i + 1].chars().collect::>()[j]) {
valid = true;
}
if j > 0 {
if parts.contains(&lines[i + 1].chars().collect::>()[j - 1]) {
valid = true;
}
}
if j < chars.len() - 1 {
if parts.contains(&lines[i + 1].chars().collect::>()[j + 1]) {
valid = true;
}
}
}
if j > 0 {
if parts.contains(&lines[i].chars().collect::>()[j - 1]) {
valid = true;
}
}
if j < chars.len() - 1 {
if parts.contains(&lines[i].chars().collect::>()[j + 1]) {
valid = true;
}
}
}
else {
if valid == true {
sum += num;
}
num = 0;
valid = false;
}
if j == chars.len() - 1 {
if valid == true {
sum += num;
}
num = 0;
valid = false;
}
}
}
return sum;
}
fn part2(input: String) -> u32 {
let lines = input.lines().collect::>();
let mut gears: Vec<(usize, usize, u32)> = Vec::new();
let mut sum = 0;
for i in 0..lines.len() {
let mut num = 0;
let chars = lines[i].chars().collect::>();
let mut pos: (usize, usize) = (0, 0);
let mut valid = false;
for j in 0..chars.len() {
let character = chars[j];
let parts = ['*'];
if character.is_digit(10) {
num = num * 10 + character.to_digit(10).unwrap();
if i > 0 {
if parts.contains(&lines[i - 1].chars().collect::>()[j]) {
valid = true;
pos = (i - 1, j);
}
if j > 0 {
if parts.contains(&lines[i - 1].chars().collect::>()[j - 1]) {
valid = true;
pos = (i - 1, j - 1);
}
}
if j < chars.len() - 1 {
if parts.contains(&lines[i - 1].chars().collect::>()[j + 1]) {
valid = true;
pos = (i - 1, j + 1);
}
}
}
if i < lines.len() - 1 {
if parts.contains(&lines[i + 1].chars().collect::>()[j]) {
valid = true;
pos = (i + 1, j);
}
if j > 0 {
if parts.contains(&lines[i + 1].chars().collect::>()[j - 1]) {
valid = true;
pos = (i + 1, j - 1);
}
}
if j < chars.len() - 1 {
if parts.contains(&lines[i + 1].chars().collect::>()[j + 1]) {
valid = true;
pos = (i + 1, j + 1);
}
}
}
if j > 0 {
if parts.contains(&lines[i].chars().collect::>()[j - 1]) {
valid = true;
pos = (i, j - 1);
}
}
if j < chars.len() - 1 {
if parts.contains(&lines[i].chars().collect::>()[j + 1]) {
valid = true;
pos = (i, j + 1);
}
}
}
else {
if valid == true {
let mut current_gear = false;
for gear in &gears {
if gear.0 == pos.0 && gear.1 == pos.1 {
sum += num * gear.2;
current_gear = true;
break;
}
}
if !current_gear {
let tuple_to_push = (pos.0.clone(), pos.1.clone(), num.clone());
gears.push((pos.0.clone(), pos.1.clone(), num.clone()));
}
}
num = 0;
valid = false;
}
if j == chars.len() - 1 {
if valid == true {
let mut current_gear = false;
for gear in &gears {
if gear.0 == pos.0 && gear.1 == pos.1 {
sum += num * gear.2;
current_gear = true;
break;
}
}
if !current_gear {
let tuple_to_push = (pos.0.clone(), pos.1.clone(), num.clone());
gears.push((pos.0.clone(), pos.1.clone(), num.clone()));
}
}
num = 0;
valid = false;
}
}
}
return sum;
}
fn main() {
let input = fs::read_to_string("data/input.txt").unwrap();
println!("{}", part1(input.clone()));
println!("{}", part2(input.clone()));
}
Im not sure how lemm.ee handles it but a lot of instances that aren't lemm.ee dont have uploads disabled
For example this post has an image uploaded to .world
Started a bit late due to setting up the thread and monitoring the leaderboard to open it up but still got it decently quick for having barely touched rust
Probably able to get it down shorter so might revisit it
yeah should hopefully calm down tomorrow now that the initial jump is done and since youre doing it relative to what the values used to be so the values themselves shouldnt matter
there might still be spikes from dead communities suddenly getting activity (since the increase from 0 is much larger those communities would go to the top of the list. Could artificially decrease large active user changes from the instance by taking the square root of the percent instead of the actual percent for percents above 100% (1) or something)
Taking into account votes is going to be how the active users is handled for any instances running pangora (lemmy fork)
Viewing the instance communities from another instance thats just using lemmy will show the old stats if needed though
note the programming.dev one has more subscribers (although both are around the same) and more activity now, lemmy just doesnt show accurate numbers in local instances
hasnt had a chance to grow until recently since aoc hasnt happened yet
if the admins in world dont get back to you if you want I can add you to the p.d one
I am noticing where its posting and im adjusting it accordingly based on that
I just didnt see a spot that has more comments than daily users as you said from the spots its posted to,but it has been posting to locations in general
The suggestion there I have fixed. The C programming language isnt being suggested anymore and dotnet and C# dont suggest each other anymore. I usually delete or edit the bots messages to account for my tweaks but forgot to do so there due to it being one of the first so ill do that now, ill also go and do the same for the rest of the bots messages. I agree other people shouldnt need to clean it up which is why ive been doing so and will do the rest now
again 1 comment occasionally isnt spam. This is just the same things over and over though in this chain so will stop on this chain. Just note I will clean up future bot messages and tweak it if it posts incorrectly which it should be doing much less now that its been refined. Other people shouldnt be needing to clean it up (if you call opting out as maintenance work its just one dm to send me and I can then deal with it) and it shouldnt be overwhelming communities. If I deem its been doing fine I can swap it to auto crosspost in the future although this doubles as leading people to post their future posts in that community without needing the bot
which communities? And triggering is relevant since by reducing how its triggered it reduces the about the comments it posts or as you like to call them spam
Ive responded so many times at this point saying why its not spam and why they add value
Just for you ill add a rule that it cant trigger on any of your posts
The article on c/programming was about postgresql and the article on c/postgresql was about performance. Both were articles that could be crossposted to those communities and both are communities that need some more activity so the bot just lets the author and people who enjoy that post know about a community they may not otherwise know about.
Based on firing without me tweaking it to remove that case its fired twice in the past two days, once today and once yesterday out of all of the posts posted to the instance which is barely anything and is nowhere close to spam. There was 46 posts in the instance total today and 85 in the past two days. Its also one comment that can easily be ignored and will be buried by other comments due to how lemmy's default comment sort works with putting newer comments at the top
If you severely dislike the bot you can block it and you will no longer see those comments
I leave this comment ulrik gave you

Yeah currently exists on lemmy.ml as well. I know some people prefer to not use that instance though due to the owners and this one is grouped in with a bunch of development communities in programming.dev
Yeah ive listened to the frozen synapse ost a bunch, especially a functioning god. Ill check out dune
Ategon
0 post score0 comment score
I checked your post history, are you talking about this post from a year ago? https://programming.dev/post/749664 (that one has only a couple downvotes which usually is standard as most posts get a couple downvotes though)
Its the kind of thing thats very difficult to solve since not everyone gets it and seems like it pops up randomly (havent been able to clearly reproduce it yet)
Were you also on mobile firefox using the site? Or was the firefox you were using on pc