A Neat XOR Trick

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • advent

    Solutions to https://adventofcode.com/ (by tsenart)

  • riscv-bitmanip

    Working draft of the proposed RISC-V Bitmanipulation extension

  • RISC-V does have a proposed extension Zbb that includes the cpop and cpopw instructions. It doesn't seem to have much recent activity, though.

    https://github.com/riscv/riscv-bitmanip/blob/main/bitmanip/i...

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • advent-of-code-2022

    🎄 My Advent of Code solutions in Rust. http://adventofcode.com/2022 (by timvisee)

  • I did something similar and counted from the end, to make much bigger jumps!

    https://github.com/timvisee/advent-of-code-2022/blob/master/...

    Maybe a bit less neat in the binary sense, but definitely very fast.

  • jdk8u-jdk

  • Note that for enumerable domains of less than 64, using a long plus bit ops has been a standard Set implementation for quite a while. For example, Java's EnumSet uses a long if the enum has less than 64 values:

    https://github.com/frohoff/jdk8u-jdk/blob/master/src/share/c...

    Where add() uses `|= bitmask`, remove() uses `&= ~bitmask`, and size() uses a count of the 1's in the long.

    Adding XOR as an efficient toggle would be interesting, but unnecessary to keep this O(n), if I understand correctly. It's just toggling the value, so (albeit with an extra branch), you could implement it as:

        if (!set.contains(val)) {

  • https://github.com/erikcorry/advent-of-code-2022/blob/main/d...

    Then a friend solved it with regular expressions, but I found a sicker regex. After all, that's what regexes are about.

    https://mobile.twitter.com/erikcorry/status/1600524753596456...

  • You are right. The algorithm you described is very similar to this XOR one. However, I did some benchmarks[0] and non-XOR version was 40% slower to XOR version when compiled with target-cpu=native. Unfortunately, without `target-cpu=native` the xor version was 40% slower and plain old arrays won!

    [0]: https://github.com/mpawelski/adventofcode2022_day06/blob/mas...

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • [2022 Day 16 (Part 1)][TypeScript] Can someone explain the general logic?

    2 projects | /r/adventofcode | 16 Dec 2022
  • 2022, Day 13, Part 1, Debugging advice please

    1 project | /r/adventofcode | 13 Dec 2022
  • -🎄- 2022 Day 3 Solutions -🎄-

    250 projects | /r/adventofcode | 2 Dec 2022
  • Apple hiring compiler developers for improving Swift / C++ interoperability

    4 projects | news.ycombinator.com | 13 Jan 2024
  • -❄️- 2023 Day 11 Solutions -❄️-

    145 projects | /r/adventofcode | 10 Dec 2023