Skip to main content

All Questions

Tagged with
2votes
2answers
130views

Project sequence to multiple sequences using LINQ (or extension methods)

I'm creating a method that expands a sequence. This is a sample of how it works: Input: {1, 2, 3} Output: {1}, {1, 2}, {1,2,3} So far, I've been able to solve the ...
SuperJMN's user avatar
1vote
1answer
152views

Eliminating repetitions of subsequent items in a list

I would like to convert a list AA = {1, 12, 3, 3, 3, 8, 5, 5 } into list B ...
SuperJMN's user avatar
0votes
1answer
195views

Simplifying for loops that includes conditions with better linq queries

The code below selects all items that are locked. How can I optimise it? ShopItemData doesn't contain a field for locked/unlocked. ...
Çağatay IŞIK's user avatar
4votes
2answers
196views

Finding which items have at least one common value with other items

I have the following collection : ...
tigrou's user avatar
3votes
1answer
966views

Non brute force algorithm for Birthday Chocolate

Problem: https://www.hackerrank.com/challenges/the-birthday-bar/problem Lily has a chocolate bar that she wants to share it with Ron for his birthday. Each of the squares has an integer on it. She ...
David's user avatar
5votes
1answer
95views

Representing relations between devices when presented with only one-to-many mappings

There are devices that communicate between each other. Already existing in the Legacy codebase is a list of one-to-many mappings between the devices. I have written a function in my backend that ...
ValarMorghulis's user avatar
9votes
3answers
783views

LINQ-ifying Colour Generation from Strings

Recently I was thinking about how Google, Microsoft Outlook on Windows Phone (and now many others) method of giving you a coloured icon with a letter in the centre of it works. Essentially, given ...
Der Kommissar's user avatar
2votes
2answers
896views

Get first DateTime by given weekdays and a starttime

At work there is an input-system where customers are able to specify weekdays and a starting time for an event. The weekdays are integers in the range from 1 (Monday) to 7 (Sunday). After the customer ...
nonsensation's user avatar
3votes
1answer
175views

Rolling up Invoice Items Matching Certain Criteria

I have a listing of invoice line items that I need to apply some convoluted business logic to. We have another listing of items that I compare the invoice items to and if I find matches, I then need ...
Michael McGriff's user avatar
3votes
2answers
117views

How to find contradiction in order of items in multiple sequences

Suppose you have several sequences: A: 1 2 3 4 5 B: 2 4 5 C: 2 1 3 4 5 D: 3 2 Here, some pairs of list contradicts each other, because they ...
Ahmad's user avatar
0votes
1answer
535views

Select values from two collections

I have a model: ...
StepUp's user avatar
23votes
5answers
4kviews

Linq me a FizzBuzz

I got this requirement recently: Write some code that prints out the following for a contiguous range of numbers: the number 'fizz' for numbers that are multiples of 3 'buzz' for numbers that are ...
user2858451's user avatar
0votes
1answer
229views

Approximate integral in one line of code

This is what I came up with: Version 1: ...
John Smith's user avatar
7votes
3answers
8kviews

Searching all diagonals of a 2D M x M array

I've started writing a piece of code to help me search for an object in all the objects found in the diagonals of an M x M 2D array. Though the code works, I'd like to know if there is a way I can ...
TheJackal's user avatar
6votes
2answers
5kviews

Determining expiration date based on list of months in which to refresh

I have a list of months in which users are required to update some data. I want to determine at what date they should have updated their data. They must update in March, May and August. If today is ...
comecme's user avatar

153050per page
close