예제 #1
0
        public override object SolvePart1(bool[,] input)
        {
            for (int turn = 0; turn < 100; turn++)
            {
                var newGrid = new bool[input.GetLength(0), input.GetLength(1)];
                for (int x = 0; x < input.GetLength(0); x++)
                {
                    for (int y = 0; y < input.GetLength(1); y++)
                    {
                        var adjacentCount = Directions.Count(dir => IsSet(input, (x + dir.dX, y + dir.dY)));
                        newGrid[x, y] = adjacentCount == 3 || input[x, y] && adjacentCount == 2;
                    }
                }

                input = newGrid;
            }

            var count =
                (from x in Enumerable.Range(0, input.GetLength(0))
                 from y in Enumerable.Range(0, input.GetLength(0))
                 where input[x, y]
                 select(x, y)).Count();

            return(count);
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (Optional != null)
         {
             hashCode = hashCode * 59 + Optional.GetHashCode();
         }
         if (IsSet != null)
         {
             hashCode = hashCode * 59 + IsSet.GetHashCode();
         }
         if (Type != null)
         {
             hashCode = hashCode * 59 + Type.GetHashCode();
         }
         if (Value != null)
         {
             hashCode = hashCode * 59 + Value.GetHashCode();
         }
         if (Description != null)
         {
             hashCode = hashCode * 59 + Description.GetHashCode();
         }
         return(hashCode);
     }
 }
예제 #3
0
        public int CompareTo(Address other)
        {
            int rs = Port.CompareTo(other.Port);

            if (rs != 0)
            {
                return(rs);
            }
            rs = IsSet.CompareTo(other.IsSet);
            if (rs != 0 || IsEmpty)
            {
                return(rs);
            }
            var local  = Resolved;
            var remote = other.Resolved;

            foreach (var l in local)
            {
                if (remote.Contains(l))
                {
                    return(0);
                }
            }
            return(local.Min().CompareTo(remote.Min()));
        }
예제 #4
0
        /// <inheritdoc />
        public override int GetHashCode()
        {
            var hash = 17;

            hash = (hash * 23) + IsSet.GetHashCode();
            hash = (hash * 23) + Value.GetHashCode();
            return(hash);
        }
예제 #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Id != null ? Id.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Position != null ? Position.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ IsSet.GetHashCode();
         return(hashCode);
     }
 }
예제 #6
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = IsSet.GetHashCode();
         hashCode = (hashCode * 397) ^ (BanPhoneMask != null ? BanPhoneMask.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PreBanMessage != null ? PreBanMessage.GetHashCode() : 0);
         return(hashCode);
     }
 }
예제 #7
0
                public override int GetHashCode()
                {
                    int hash = 1;

                    if (IsSet != false)
                    {
                        hash ^= IsSet.GetHashCode();
                    }
                    hash ^= shapeAndType_.GetHashCode();
                    if (_unknownFields != null)
                    {
                        hash ^= _unknownFields.GetHashCode();
                    }
                    return(hash);
                }
        /// <summary>
        /// Returns true if SamlConfigurationPropertyItemsString instances are equal
        /// </summary>
        /// <param name="other">Instance of SamlConfigurationPropertyItemsString to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(SamlConfigurationPropertyItemsString other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Optional == other.Optional ||
                     Optional != null &&
                     Optional.Equals(other.Optional)
                 ) &&
                 (
                     IsSet == other.IsSet ||
                     IsSet != null &&
                     IsSet.Equals(other.IsSet)
                 ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ) &&
                 (
                     Value == other.Value ||
                     Value != null &&
                     Value.Equals(other.Value)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ));
        }
예제 #9
0
        /// <summary>
        /// Returns true if ConfigNodePropertyArray instances are equal
        /// </summary>
        /// <param name="other">Instance of ConfigNodePropertyArray to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ConfigNodePropertyArray other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Optional == other.Optional ||
                     Optional != null &&
                     Optional.Equals(other.Optional)
                 ) &&
                 (
                     IsSet == other.IsSet ||
                     IsSet != null &&
                     IsSet.Equals(other.IsSet)
                 ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ) &&
                 (
                     Values == other.Values ||
                     Values != null &&
                     Values.SequenceEqual(other.Values)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ));
        }
예제 #10
0
파일: Option.cs 프로젝트: WooZoo86/NICE
 public void Set(T value)
 {
     _set   = Foundation.IsSet.Set;
     _value = value;
 }
예제 #11
0
    public override void OnEnter()
    {
        GlobalWindowSoundController.Instance.PlayOpenSound();
        InstallHandlers();

        //Request message to server for initialization.
        isSet = new IsSet()
        {
            Sclotterylist = false,
            Sclotterycomposelist = false
        };
        var msg = new CSLotteryList();
        NetManager.SendMessage(msg);
    }