This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Application { | |
static String solve(String word) { | |
Objects.requireNonNull(word); | |
Map<String, Integer> chars = new LinkedHashMap<String, Integer>(); | |
for (int i = 0; i < word.length(); i++) { | |
var w = word.charAt(i); | |
chars.compute(String.valueOf(w), (k, v) -> { | |
if (v != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE NoImplicitPrelude #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect } from "react"; | |
import { connect, styled } from "frontity"; | |
import Link from "./link"; | |
import List from "./list"; | |
import Item from "./list/list-item"; | |
import FeaturedMedia from "./featured-media"; | |
const Post = ({ state, actions, libraries }) => { | |
// Get information about the current URL. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const promiseWithTimeout = (timeoutMs, promise, failureMessage) => { | |
var timeoutHandle; | |
const timeoutPromise = new Promise((resolve, reject) => { | |
timeoutHandle = setTimeout(() => reject(new Error(failureMessage)), timeoutMs); | |
}); | |
return Promise.race([ | |
promise, | |
timeoutPromise, | |
]).then((result) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com; | |
import static java.lang.String.valueOf; | |
import static java.util.Objects.isNull; | |
import static java.util.Objects.nonNull; | |
import java.util.ArrayList; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.stream.Collectors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example.controller | |
import arrow.fx.reactor.FluxK | |
import arrow.fx.reactor.extensions.fluxk.async.effect | |
import arrow.fx.reactor.value | |
import example.ParserService | |
import org.springframework.web.bind.annotation.GetMapping | |
import org.springframework.web.bind.annotation.RequestParam | |
import org.springframework.web.bind.annotation.RestController | |
import reactor.core.publisher.Flux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::cmp::Ordering; | |
use std::io; | |
use rand::Rng; | |
fn main() { | |
println!("Guess the number!"); | |
let secret_number = rand::thread_rng().gen_range(1, 101); | |
let mut attempts : Vec<u32> = Vec::new(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.pauljamescleary.petstore.domain.destination | |
import scala.language.higherKinds | |
trait DestinationRepositoryAlgebra[F[_]] { | |
def destinations(departureId: Long): F[List[Long]] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FindOutlier { | |
public static int find(int[] numbers) { | |
int lastOdd = 0; | |
int lastEven = 0; | |
int totalOdd = 0; | |
int totalEven = 0; | |
for (int i = 0; i < numbers.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solve(students, music): | |
s = students[:] # simply copy the list to not mutate | |
zeroed_music = music - 1 # shit music index to 0 | |
delete_at = zeroed_music % len(s) # decides where to delete mod the size of students | |
while len(s) > 1: | |
print('Considering students %s and index %s' % (s, delete_at)) | |
del s[delete_at] | |
delete_at = (delete_at + zeroed_music) % len(s) | |
return s[0] |
NewerOlder